Mobius1 / Selectr

A lightweight, vanilla javascript select box replacement. No dependencies.
MIT License
313 stars 77 forks source link

Selectr is not idempotent #145

Open rnickmccandless opened 4 years ago

rnickmccandless commented 4 years ago

When instantiating an instance of new Selectr(element) with the same element multiple times, Selectr generates new HTML markup resulting in duplicating drop downs.

Unexpected result: Screen Shot 2020-05-27 at 1 09 16 AMe

This was first noticed when using Turbolinks while navigating the website forward, then back.

* I understand that at this time, the project is not being maintained. Hopefully this project will see a new maintainer soon since Selectr has been a great simple way to apply a better select element.

Xaraxia commented 4 years ago

I've worked around this problem by detecting the classes on the underlying element, and not making the Selectr call if it doesn't exist. Suboptimal, yes, but it works.