import { Controller } from '@hotwired/stimulus'; /** * 동적으로 부모-자식 선택 옵션을 업데이트하는 컨트롤러 */ export default class extends Controller { static targets = ['parent', 'child']; static values = { json: Object }; connect() { this.updateChild(); } updateChild() { const parent = this.parentTarget.value; const children = this.jsonValue[parent] || []; if (children.length === 0) { this.childTarget.innerHTML = ''; this.childTarget.hidden = true; this.childTarget.disabled = true; this.childTarget.classList.add('hidden'); } else { this.childTarget.innerHTML = children.map((c) => ``).join(''); this.childTarget.hidden = false; this.childTarget.disabled = false; this.childTarget.classList.remove('hidden'); } } }

AltStyle によって変換されたページ (->オリジナル) /