我有一个正在使用 select2 的数组,但我希望多次选择相同的值。有没有办法启用这个功能?我的代码如下:
#home.js
$(document).ready(function(){
$("#productdropdown").select2({
allowClear: true,
placeholder: "Select a product..."
});
});
那么在我看来
#index.html.erb
<%= form_tag manuals_path, method: :post, remote: true do %>
<%= form_tag manuals_path, method: :post, remote: true do %>
<%= select_tag :device, options_from_collection_for_select(@products, :id, :full_name), id: "productdropdown", multiple: true %>
<%= submit_tag 'CREATE MYMANUAL', class: 'submit', id: "generate" %>
<% end %>
并在控制器中
def index
@products = Product.usable
end