selectize.js reload dropdown

Obaid Ahmed picture Obaid Ahmed · May 26, 2015 · Viewed 23.6k times · Source

I have a dropdown with id "selectCountry" filled by ajax and on success I just bind the Selectize.

$('#selectCountry').selectize({
    create: true,
    sortField: 'text' 
});

When I rebind my original dropdown by ajax and try to reload/rebind or refreshed the old selectize auto complete box on success, there would be no change on old list.

Is there any way to reload or refresh selectize dropdown? I had try "clearOptions()" and "refreshOptions()".

P.S, I don't want to directly bind the selectize from ajax.

OK, now I am adding working example for this issue on jsfiddle

Please help me :( any suggestion would be great for me. Thanks alot

Answer

Obaid Ahmed picture Obaid Ahmed · May 28, 2015

Some how, I found the answer and its working here

just add this line of code and its working.

$('#select-tools').selectize()[0].selectize.destroy();