Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

Multiple selects added at runtime get mixed up #31

Open
vtenext-dan opened this issue Nov 12, 2015 · 1 comment
Open

Multiple selects added at runtime get mixed up #31

vtenext-dan opened this issue Nov 12, 2015 · 1 comment
Labels

Comments

@vtenext-dan
Copy link
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
          }
        });
@FezVrasta
Copy link
Owner

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants