Reputation: 1690
I have my select:
<select id="fields_u" multiple="multiple"></select>
I appended the fields dynamically:
$('#fields_u').append(fields_html);
//or
$('#example-select').append($('<option>', {
value: 'optionValue',
text: 'optionText'
}));
Start the plugin:
$('#fields_u').multiselect();
Trying to select:
$('#fields_u').multiselect('select', ['0', '1'...]);
Not working...
This worked for me when the fields where on the DOM.
Is it a known issue?
EDIT! Works, very sorry, silly me. I was sure you put the fields indexes in the select and not the fields names.
Upvotes: 3
Views: 2309
Reputation: 82241
You need to refresh multiselect after appending the options dynamically:
$('#fields_u').multiselect('refresh');
Upvotes: 4