Getting chips data in Materialize css through Post

本秂侑毒 提交于 2019-12-11 04:03:50

问题


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.

I wrote a jquery code to verify this

$('#showvalues').on('click', function(){
    alert($('#emotiontags').val())   
})

and my chips code looks like

<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


回答1:


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);


来源:https://stackoverflow.com/questions/47898366/getting-chips-data-in-materialize-css-through-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!