Sha256: 6d4c474345dc483eb4d5de2eae49782e4dd1f50ee348bd5434b9b98bd7e23eda
Contents?: true
Size: 648 Bytes
Versions: 24
Compression:
Stored size: 648 Bytes
Contents
import { Controller } from "@hotwired/stimulus"; export default class OrderableFormController extends Controller { static values = { scope: String }; add(item) { item.params(this.scopeValue).forEach(({ name, value }) => { this.element.insertAdjacentHTML( "beforeend", `<input type="hidden" name="${name}" value="${value}" data-generated>`, ); }); } submit() { if (this.inputs.length === 0) return; this.element.requestSubmit(); } clear() { this.inputs.forEach((input) => input.remove()); } get inputs() { return this.element.querySelectorAll("input[data-generated]"); } }
Version data entries
24 entries across 24 versions & 1 rubygems