nobleclem/jQuery-MultiSelect

ajax on search

sali-karwasolutions opened this issue · 2 comments

I want to use multi-select with additional feature of ajax search.

I would like to search a result from any given url and load that as multi-select options.

I have search for option for similar functionality but couldn't find answer, Please suggest if I am doing it right.

$.ajax({
type: "Get",
url: ${searchUrl}${text},
dataType: "json",
success: function (orgUnits) {
orgUnits.forEach(function (orgUnit) {
$(elementId).append(new Option(orgUnit.name, orgUnit.id));
});
},
error: function (e) {
console.log(e);
}
});

Look at the example Dynamically Populate List on the Demo Page.

Basically you will get your options from your ajax call. Then use the loadOptions method to populate the select list.

Alternatively you can manually add options to the select list and then call the reload method $('select[multiple]').multiselect('reload');.

Oh also check out issue #3

thank you that worked like a charm, some of the examples referred to reload as refresh which I think is not a method which caused by code not working as intended.