Select2 does not detect multiple attribute in my jquery

57 Views Asked by At

I am using the select2 gem in a rails app, I cannot get the form to accept multiple values in my ("id").select2()

I would like it to detect the multiple:true attribute in my jquery and not in my select input but it doesn't work for me

for example:

this is my imput tags

= f.input :tag_ids, collection: [], input_html: { class: "js-example-basic-multiple js-example-responsive", id: "js-customer"}, include_blank: false

my jquery

 $("#js-customer").select2({
          maximumSelectionLength: 5,
          minimumInputLength: 1,
          multiple: true,
          tags: true,
          data: (#{Tag.order(:name).map{|tag| {id: tag.id, text: tag.name}}.to_json.html_safe}),
    });

What I am looking for is that I detect the multiple:true attribute in my jquery

1

There are 1 best solutions below

1
Tibic4 On

Try adding the multiple attribute to the input Tag:

<%= f.input :tag_ids, collection: [], input_html: { class: "js-example-basic-multiple js-example-responsive", id: "js-customer", multiple: true}, include_blank: false %>