0
私は以下のコーヒースクリプトを持っています。リモートAjax select2を実行すると、これはすべてのクラスselect2-autocompleteを設定します。問題は、このスクリプトを追加したばかりの項目以下 coffeescriptのjqueryセレクタからそれぞれを削除します
$('.select2-autocomplete').each (i, e) ->
select = $(e)
options =
multiple: false
width: "98%"
placeholder: "Type Hotel name"
minimumInputLength: 3
options.ajax =
url: select.data('source')
dataType: 'json'
type: "GET"
quietMillis: 150
# input untuk program
data: (term) ->
q: term
results: (data) ->
results: $.map(data, (item) ->
text: item.name
id: item.id
)
options.dropdownCssClass = 'bigdrop'
select.select2 options
は私のHTMLコード、ノートはどのように私は反復各せずに以下のスクリプトを変更し、:私はSELECT2のv.3.5.3のAJAXを使用していますので、私は隠しフィールド(レール)
<%= f.hidden_field :hotel_id, data: { source: search_name_hotels_path }, class: "select2-autocomplete", :value => "#{f.object.hotel_id unless f.object.new_record? || f.object.hotel_id.nil? }" %>
を使用しています
以下のようにあなたがありがとうコード –