我有一个数组,我正在使用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