dropdown.js icon indicating copy to clipboard operation
dropdown.js copied to clipboard

Multiple selects added at runtime get mixed up

Open vtenext-dan opened this issue 8 years ago • 1 comments

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
          }
        });

vtenext-dan avatar Nov 12 '15 16:11 vtenext-dan

Thanks, may you send a PR with this edit? Thanks.

FezVrasta avatar Nov 12 '15 19:11 FezVrasta