bootstrap-multiselect
bootstrap-multiselect copied to clipboard
Observing Classes
Is there a way to make this work with dynamically added classes? As in, if elements with a class are dynamically added to the page? E.g .multiselect for product selector that's added to the page after a 'Add product' button click?
Not really. You would need to call .multiselect() on the newly-added content, or have something like:
function reinitMultiSelect(selector) {
// Remove all existing multiselects
$(selector).multiselect('destroy');
// Apply plugin to all matching elements
$(selector).multiselect();
}
You'd call this after whatever code adds your new select elements. You're probably better off just applying the plugin to only your new content, though, as something like that example could be quite memory and/or CPU intensive, if you have a lot of selects on the page.