2017-08-24 29 views
0

您好我使用Materialise的CSS和symfony中, 當我渲染choicesType元素的symfony中添加選擇選項Materialise的重載的jQuery

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

和選擇顯示:無

我的目標是在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
$("#indirizzo_row select").material_select(); 

$("#appbundle_select_id").material_select(); 

嘗試測試。 您需要使用Select元素。

0

我明白我錯了

$("#select_id").material_select(); 

工作比前

$("#select_id").load(location.href+" #select_id>*",""); finish. 

所以我

$("#select_id").load(location.href+" #select_id>*",function(){ 

        $('select').material_select(); 
       }); 
解決
相關問題