-
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
I'm using [use-bootstrap-select] in my Ruby on Rails app together with a Stimulus controller:
this.select = new UseBootstrapSelect(this.element)
When navigating to another page and then using the back button in the browser the select forms are now visually duplicated. One of them is not working though.
I've come up with a bit hacky workaround.
I am assigning unique ids to my select tags, so that it's possible to have multiple instances:
document.querySelectorAll(`[data-select-id="${this.element.id}"]`).forEach((el) => {
el.remove()
})
this.select = new UseBootstrapSelect(this.element)
const bootstrap_select = this.element.nextElementSibling
bootstrap_select.setAttribute("data-select-id", this.element.id)
It's not possible to check if new UseBootstrapSelect has been called on an element or not. And also the generated .use-bootstrap-select-wrapper can not be linked back to the element.
Metadata
Metadata
Assignees
Labels
No labels