Sha256: ccf19bf5aff61818052e41d6782bcb8ed1ad281e36c746a7d7fa895052feb326
Contents?: true
Size: 582 Bytes
Versions: 45
Compression:
Stored size: 582 Bytes
Contents
import { Controller } from '@hotwired/stimulus' export default class extends Controller { static targets = ['select', 'type', 'container'] connect() { this.changeType() // Do the initial type change } changeType() { this.#hideAllTypes() this.#showType(this.selectTarget.value) } #hideAllTypes() { this.containerTarget.innerHTML = '' } #showType(type) { const target = this.typeTargets.find((typeTarget) => typeTarget.dataset.type === type) if (target) { this.containerTarget.appendChild(target.content.cloneNode(true)) } } }
Version data entries
45 entries across 45 versions & 1 rubygems