Open longqnh opened 7 years ago
View this post https://github.com/lou/multi-select/issues/193
$('#my-multi').empty().multiSelect('refresh');
I am trying to do something like this:
$mySelect.empty().multiSelect('refresh').multiSelect({ allMyOptions });
so that my table will be reinitialized each time my function is called, at which point new options will repopulate in my multiSelect.
allMyOptions
contains many pieces of logic and events that I need to run, ex: afterSelect
, afterDeselect
but... multiSelect('refresh')
invalidates all my options/events.
My multiSelect contains a list of user roles. Some of those roles are disabled, some are enabled. Refresh invalidates that logic, but I don't want it to.
I have also tried:
$multiSelect('destroy').multiSelect({ allMyOptions });
but this does not actually reinitialize the multiSelect.
I am at a loss... any suggestions?
This is what worked for me.
Add into the jquery.multi-select.js (under the destroyer - or in that section):
'removeAllOptions' : function(){
this.destroy();
this.$element.find('option').remove();
this.$element.multiSelect({});
},
Then call:
$('#my-select').multiSelect('removeAllOptions');
Try This Removing Options for Multiple Select Drop Down.
$('#FeatureId').multiselect("deselectAll", false).multiselect("refresh");
View this post #193
$('#my-multi').empty().multiSelect('refresh');
this works perfect, but it remove the optgroup how to keep the groups or add them again ?
@ahmedabushaaban how can i remove the ptgroup ???
when we use this $('#my-multi').empty().multiSelect('refresh'); select header details are also not displaying.
Do this...
$("#my-multi option:selected").prop("selected", false); $("#my-multi option").remove(); $('#my-multi').multiselect('rebuild');
working for me $("#selectedVariables option:selected").prop("selected", false); $("#selectedVariables option").remove(); $('#selectedVariables').multiselect('rebuild');
View this post #193
$('#my-multi').empty().multiSelect('refresh');
Thank you so much, it work properly.
$("#my-multi option:selected").prop("selected", false); $("#my-multi option").remove(); $('#my-multi').multiselect('rebuild'); work perfect you have to adjust $('#my-multi').multiselect('rebuild'); up-down
Dear all, If I have a multiselect like:
<select id='pre-selected-options' multiple='multiple'>
<option value='elem_1'>elem 1</option>
<option value='elem_2'>elem 2</option>
<option value='elem_3'>elem 3</option>
<option value='elem_4'>elem 4</option>
</select>
$('#pre-selected-options').multiSelect();
I wanna remove all options in
#pre-selected-options
. How can I do it?