You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
508 B
17 lines
508 B
import { Controller } from "@hotwired/stimulus"
|
|
|
|
// Connects to data-controller="toggle-visibility"
|
|
export default class extends Controller {
|
|
|
|
static values = { selector: String }
|
|
|
|
connect() {
|
|
this.foundElements = document.querySelectorAll(this.selectorValue)
|
|
if (this.foundElements.length == 0)
|
|
console.warn(`${this.identifier}: no element found for CSS selector='${this.selectorValue}'`)
|
|
}
|
|
|
|
toggle() {
|
|
this.foundElements.forEach(element => element.hidden = !element.hidden)
|
|
}
|
|
}
|