Sha256: f596dc5e9c1adfb68ad7d9d5931e04d090364427108510c849ce7689c29eca6a
Contents?: true
Size: 885 Bytes
Versions: 6
Compression:
Stored size: 885 Bytes
Contents
import {Controller} from "stimulus" export default class extends Controller { static get targets() { return ["form", "select", "method", "button"] } connect() { this.wrapperClass = "table-actions" } update(event) { event.preventDefault() const option = this.selectTarget.options[this.selectTarget.selectedIndex] // Replace form action this.formTarget.action = this.selectTarget.value // Replace form method this.methodTarget.value = option.dataset.method // Set confirm on form button const confirm = option.dataset.confirm if(confirm) { this.buttonTarget.dataset.confirm = confirm } else { this.buttonTarget.removeAttribute('data-confirm') } // Enable button this.buttonTarget.removeAttribute('disabled') } }
Version data entries
6 entries across 6 versions & 1 rubygems