ehynds / jquery-ui-multiselect-widget

jQuery UI MultiSelect widget

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Destroying the multiselect prevents from recreating it with a filter.

alons1 opened this issue · comments

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

Are you seeing any errors in the console?

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

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.

commented

Ah..
Good to know!
But probably not a desired behavior?
I would expect the filter to be destroyed when I destroy the multiselect

If you want to submit a PR that seems like a reasonable change.