Search code examples
javascriptjquerytwitter-bootstrapbootstrap-multiselect

Options not being posted by Bootstrap Multiselect


I'm using Bootstrap Multiselect (https://github.com/davidstutz/bootstrap-multiselect). It's a great component but i'm having the issue described below.

Let's say i have a select with id 'select-status' with 10 options and i want the app opens by default with the first 3 options selected. For this i'm using this code :

$(function () {
    $('#select-status').multiselect('select','1');
    $('#select-status').multiselect('select','2');
    $('#select-status').multiselect('select','3');
});

I can see the code above works because the 3 options appear checked when i load my application.

The problem is, when i submit the form, only one option is being posted, UNLESS i manually click on the select dropdown to show the options. Only by doing this and not even clicking in any option, the form will post correctly, with the 3 selected options.

I assume that probably i need to do some code after i select the options programatically.

Any hints ?

Thanks !


Solution

  • What if you use an array of values instead?

    $('#select-status').multiselect('select', ['1', '2', '3']);
    

    It would be interesting to see the rest of your markup too, though. And also hear what you use to grab the data.