Multiple selects added at runtime get mixed up #31

Open
magikozio opened this Issue Nov 12, 2015 · 1 comment

Projects

None yet

2 participants

Contributor

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

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

@FezVrasta FezVrasta added the bug label Nov 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment