dropdown.js
dropdown.js copied to clipboard
Multiple selects added at runtime get mixed up
When using the autoinit option and a HTML block with multiple selects is added a runtime, the resulting dropdowns get mixed up (one of them contains all the options, and the others are not clickable). To fix this, I changed the autoinit handler to support multiple selects:
$(document).on("DOMNodeInserted", function(e) {
var $this = $(e.target);
if (!$this.is("select")) {
$this = $this.find('select');
}
if ($this.is(options.autoinit)) {
initElement($this);
}
});
with this
$(document).on("DOMNodeInserted", function(e) {
var $this = $(e.target);
if (!$this.is("select")) {
$this = $this.find('select');
}
if ($this.is(options.autoinit)) {
// this is the changed part
$this.each(function() {
initElement($(this));
});
// end of patch
}
});
Thanks, may you send a PR with this edit? Thanks.