Destroying the multiselect prevents from recreating it with a filter.
alons1 opened this issue · comments
Alon commented
$('#myField').multiselect({ buttonWidth: null, header: [], noneSelectedText: 'Select', selectedText: '# selected' }).multiselectfilter({ width: 200, label: 'Search:' });
$('#myField').multiselect('destroy');
$('#myField').multiselect({ buttonWidth: null, header: [], noneSelectedText: 'Select', selectedText: '# selected' }).multiselectfilter({ width: 200, label: 'Search:' });
filter does not show up the second time
Michael Harris commented
Are you seeing any errors in the console?
Michael Harris commented
Actually I was able to reproduce this just by opening the unit tests index page in a browser and doing:
var select = $("select")
select.multiselect("destroy") // get rid of current widget
select.multiselect().multiselectfilter() // has filter
select.multiselect("destroy")
select.multiselect().multiselectfilter() // no filter!
and there were no errors in the console when I did this
Michael Harris commented
Ah, I remember now!
select.multiselect().multiselectfilter() // has filter
select.multiselect().multiselectfilter("destroy")
select.multiselect("destroy")
select.multiselect().multiselectfilter() // has filter again!
You have to destroy the filter before destroying the widget if you want to manually collect them and do it again.
Alon commented
Ah..
Good to know!
But probably not a desired behavior?
I would expect the filter to be destroyed when I destroy the multiselect
Michael Harris commented
If you want to submit a PR that seems like a reasonable change.