Closed chenyb888 closed 7 years ago
Hi!
Multi always matches the select element it was initialized on. I would suggest you clear out the selection between uses of the popup and then trigger a change
event on the select element to update multi.
Here's an example:
// Init multi.js with select_element
multi( select_element, {
'enable_search': true,
'search_placeholder': 'Search...',
});
// Do something else...
// Clear select_element selection
for ( var i = 0; i < select_element.options; i++ ) {
select_element.options[i].selected = false;
}
// Create and trigger change event on element (to make sure multi updates)
var e = document.createEvent( 'HTMLEvents' );
e.initEvent( 'change', false, true );
select_element.dispatchEvent( e );
thanks. but it's too complex. why do not implement a method just like .refresh()?
with jquery you can use:
$( '#mylist" ).val([]);
$( '#mylist" ).trigger( "change" );
great plugin. .refresh function would be nice.
ok,thank you
I'm using multi in a popup , after i close the popup and pop again, there's old value in multi. how to clean it?