vendredi 21 octobre 2016

Select options from multi-select dropdown

I am using select_tag from rails with bootstrap multi-select functionality. I am able to show options. But how to select options using jquery on page load.

select tag code <%= select_tag 'test', options_from_collection_for_select(@test, "id", "name"), :class => "form-control", :multiple => "multiple" %>

$('#test').multiselect({ 
  includeSelectAllOption: true,
  enableFiltering:true         
});  

When i use

 $("#test").val(["some_value_of_option", "some_value_of_option"]).prop("selected", true);

The above code is not working to select options. Thanks in advance for help..

Aucun commentaire:

Enregistrer un commentaire