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.
 
 
 
 
 

18 lines
527 B

import { Controller } from "@hotwired/stimulus"
// Connects to data-controller="hidden"
export default class extends Controller {
static values = { toggler: String }
connect() {
const toggler = document.getElementById(this.togglerValue)
if (toggler == undefined) {
console.warn(`no toggler: <input type=checkbox id=${this.togglerValue}> missing!`)
return
}
this.element.hidden = !toggler.checked
toggler.addEventListener('change', () => { this.element.hidden = !toggler.checked })
}
}