通过Post在Materialize CSS中获取芯片数据 [英] Getting chips data in Materialize css through Post
问题描述
我正在尝试使用Materilize CSS的芯片来获取数据.但是,当我尝试使用表单提交数据时,没有收到任何数据. 添加芯片后,我检查输入字段的值是否为空.
I am trying to get the data using the Materilize css's chips. But no data is received when I try to submit it using a form. I checked that the input fields value was null once I added the chips.
我写了一个jquery代码来验证这一点
I wrote a jquery code to verify this
$('#showvalues').on('click', function(){
alert($('#emotiontags').val())
})
我的筹码类似于
<div class="chips chips-autocomplete col s4 offset-s3">
<input placeholder="You Emotions" id="emotiontags" type="text"
name="emotiontags">
</div>
<button class="btn waves-effect waves-light" id="showvalues">
Show values
<i class="material-icons right">send</i>
</button>
此处显示的是普通文本
Here is its out with normal text
这是我尝试添加筹码时的输出.
and here is the output when I try to add chips
推荐答案
已经6个月了,但是我想为遇到此问题的人们提供答案.根据MaterializeCSS的文档,chipsData
是用于存储当前芯片数据数组的属性.
Well it has been 6 months but I wanted to give an answer for people encountering this question. According to the documentation of MaterializeCSS, chipsData
is the property that stores an array of the current chips data.
通过类似这样的方法获取筹码元素的实例后;
After getting the instance of your chips elements by something like this;
var chipInstance = M.Chips.getInstance($(".chips"));
芯片数组可以通过以下方式访问并记录到控制台
Chips array can be accessed and logged to the console via
console.log(chipInstance.chipsData);
这篇关于通过Post在Materialize CSS中获取芯片数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!