bootstrap-multiselect rebuild/refresh not working -


i have 2 bootstrap-multiselect boxes. want refresh items in 1 based on selections made in other via ajax call.

everything work except multiselect uses disoplay options not being populated either 'rebuild' or 'refresh'.

code:

decalring multiselect"

        $('#groups').multiselect({         onchange: function (option, checked) {             //get of selected tiems             var values = $('#groups option:selected');             var selected = "";             $(values).each(function (index, value) {                 selected += $(value).prop('value') + ",";             });             selected = selected.substring(0, selected.length - 1);             //update hidden field comma delimited string state persistance             $("#hidden_groups").val(selected);         },         includeselectalloption: true     }); 

updating options list:

$('#jobcodes').multiselect({         ondropdownhide: function(event) {             console.log("start");             var option = $("#groups");             //clear out old consolidations             option.empty();             console.log("emptied");              ////get consolidation , append select options list             $.getjson("/reports/getgroups/", { options: $("#hidden_jobcodes").val() }, function (result) {                 $.each(result, function (index, item) {                     console.log(item.text);                     option.append($("<option />").val(item.id).text(item.text));                 });             });              option.multiselect('destroy');             option.multiselect('rebuild');             option.multiselect('refresh');         }, 

have left destroy, rebuild , refresh in example things have tried. have used of these in every order , combination , no luck.

destroy "change" multiselect standard select no matter after cannot multiselect come new list of options, including using full multiselect call wiht onchange event present. either empty of has old list. select list has correct options present when make refresh/rebuild calls.

thanks in advance. t

totally fault!!

the call /destroy/refresh/rebuild outside of ajax call. executing before new list had been returned, hence no list rebuild @ time.

solution:

 ////get consolidation , append select options list             $.getjson("/reports/getgroups/", { options: $("#hidden_jobcodes").val() }, function (result) {                 $.each(result, function (index, item) {                     console.log(item.text);                     option.append($("<option />").val(item.id).text(item.text));                 });                 option.multiselect('rebuild')             }); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -