Sha256: 076f3936feb6d3918c33b05956d7ff7b2cccc56e85fd4cb26ad4accc5ca15cfe
Contents?: true
Size: 817 Bytes
Versions: 6
Compression:
Stored size: 817 Bytes
Contents
// Inspired by: https://github.com/excid3/tailwindcss-stimulus-components/blob/master/src/popover.js import { Controller } from "@hotwired/stimulus"; export default class UIToggleController extends Controller { connect() {} toggle() { const button = this.element.querySelector("button"); const span = this.element.querySelector("span"); const input = this.element.querySelector("input[type='hidden']"); if (this.element.dataset.state == "checked") { input.value = "unchecked"; button.dataset.state = "unchecked"; span.dataset.state = "unchecked"; this.element.dataset.state = "unchecked"; } else { input.value = "checked"; button.dataset.state = "checked"; span.dataset.state = "checked"; this.element.dataset.state = "checked"; } } }
Version data entries
6 entries across 6 versions & 1 rubygems