在带有模态实现的轨道中添加选择形式

时间:2019-01-02 09:23:03

标签: ruby-on-rails

我想问一下如何使用materializecss模态将选择表单添加到导轨中。

这是我的_form.html.erb

<div class="row" id="inStaff">
 <div class="input-field col s4">
  <div class="control-group">
   <%= form.label :staff, class: 'control-label' %>
  <div class="controls">
   <%= form.select(:staff, options_for_select([['1', '1'],['2', '2'],['3', '3']]),{include_blank: true})%>
  </div>
  </div>
 </div>
</div>

<div class="row" id="inCustomer">
 <div class="input-field col s4">
  <div class="control-group">
   <%= form.label :customer, class: 'control-label' %>
  <div class="controls">
   <%= form.select(:customer, options_for_select([['4', '4'],['5', '5'],['6', '6']]),{include_blank: true})%>
  </div>
  </div>
 </div>
</div>

我的form.js

$(document).ready(function(){
$('select').formSelect();
});

1 个答案:

答案 0 :(得分:0)

模式打开时,您可能需要初始化选择器。

$('.modal').modal({
  onOpenStart: function(modal, trigger) {
    $('select').formSelect()
  }
});