I have chosen multiselectable.I want to change chosen from multiselect to single select on javascript code. I will send some ajax post and according to response value, I must change property of chosen. From multiselect to singleselect or oppsitely.
I ended up having to manually destroy the Chosen instance, change the multiple
attribute of the raw select element, and initialize the plugin again.
var $select = $('.my-select');
$select.chosen('destroy');
$select.attr('multiple', 'multiple');
$select.chosen();
or the inverse
$select.chosen('destroy');
$select.removeAttr('multiple');
$select.chosen();
Not super clean but Chosen doesn't appear to have a "rerender from source element" method, other than changes to the options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With