Sha256: 4df7f955629c1ab3fbdc86b6da1457b81c27ad1966a651b64a25442f162bf68c
Contents?: true
Size: 886 Bytes
Versions: 13
Compression:
Stored size: 886 Bytes
Contents
/* eslint-disable require-jsdoc */ class OptionAttachedInputsComponent { constructor(options = {}) { this.wrapperField = options.wrapperField; this.controllerFieldSelector = options.controllerFieldSelector; this.dependentInputSelector = options.dependentInputSelector; this.controllerSelector = this.wrapperField.find(this.controllerFieldSelector); this._bindEvent(); this._run(); } _run() { this.controllerSelector.each((idx, el) => { const $field = $(el); const enabled = $field.is(":checked"); $field.parents("div.js-collection-input").find(this.dependentInputSelector).prop("disabled", !enabled); }); } _bindEvent() { this.controllerSelector.on("change", () => { this._run(); }); } } export default function createOptionAttachedInputs(options) { return new OptionAttachedInputsComponent(options); }
Version data entries
13 entries across 13 versions & 1 rubygems