您好我使用Materialise css和symfony, 当我渲染choicesType元素
时<div class="row" id="indirizzo_row">
<div class="input-field col s12">
{{ form_widget(form.idIndirizzo) }}
<label for="textarea" class="">Indirizzo</label>
</div>
html结果是:
<div class="row" id="indirizzo_row">
<div class="input-field col s12">
<div class="select-wrapper initialized"><span class="caret">▼</span>
<input type="text" class="select-dropdown" readonly="true" data activates="select-options-404a0618-34d9-457a-953e-d80885817d6c" value="Value1">
<ul id="select-options-404a0618-34d9-457a-953e-d80885817d6c" class="dropdown-content select-dropdown ">
<li class=""><span>Value1</span></li>
</ul>
<select id="appbundle_select_id" name="appbundle[idIndirizzo]" class="initialized">
<option value="1221">Value,1</option></select>
</div>
<label for="textarea" class="">Indirizzo</label>
</div>
</div>
并且选择显示在:none
我的目标是在jquery重新加载字段中添加或删除选项选择值
我试试这个:
$("#indirizzo_row").load(location.href+" #indirizzo_row>*","");
(this add a option in select but not in ul li list
$("#indirizzo_row").material_select();
但它不起作用
答案 0 :(得分:0)
$("#indirizzo_row select").material_select();
或
$("#appbundle_select_id").material_select();
尝试测试。 您需要使用Select元素。
答案 1 :(得分:0)
我理解错了
$("#select_id").material_select();
之前的工作
$("#select_id").load(location.href+" #select_id>*",""); finish.
所以我决定用
$("#select_id").load(location.href+" #select_id>*",function(){
$('select').material_select();
});