我在Rails(4.2.6)app中遇到了一些材料芯片的问题。当我在我的输入字段中添加class chips-initial时,我无法为我的字段写入任何数据。那个领域是零。我不明白为什么。这个字段是String,但当这个字段为Array时,我遇到了同样的问题。
这是我的表格:
sep=,
这是初始筹码的.js
= simple_form_for @exemple do |f|
.input-field
= f.input :title
.input-field
= f.label 'content'
= f.text_area :content, class: "materialize-textarea"
.input-field.chips.chips.chips-initial.chipschips-placeholder
= f.input :tags
= f.button :submit, class: 'btn btn-primary'
in html:
$( document ).ready(function(){
$('.chips-initial').material_chip({
data: [{
tag: 'Apple',
}, {
tag: 'Microsoft',
}, {
tag: 'Google',
}],
placeholder: 'Enter a tag',
secondaryPlaceholder: '+Tag',
}
)
});
但是当我创建时,在控制台中:
<div class="input-field chips chips chips-initial chipschips-placeholder" data-index="0" data-initialized="true">
<div class="chip">Apple<i class="material-icons close">close</i></div>
<div class="chip">Microsoft<i class="material-icons close">close</i></div>
<div class="chip">Google<i class="material-icons close">close</i></div>
<input id="9c3fa6b9-b134-626b-ddbb-a0a12a538eed" class="input" placeholder="Enter a tag"></div>
<input id="9c3fa6b9-b134-626b-ddbb-a0a12a538eed" class="input" placeholder="Enter a tag">
我正在使用宝石'materialize-sass'