Sha256: 6b01a9c54f626f82c4677efa70ce7fe57ad48f9749dfebf04e15435c7fe98ff1
Contents?: true
Size: 577 Bytes
Versions: 44
Compression:
Stored size: 577 Bytes
Contents
export default class AutoSelectOptionsByTotalItemsComponent { constructor(options = {}) { this.wrapperSelector = options.wrapperSelector; this.selectSelector = options.selectSelector; this.listSelector = options.listSelector; } run() { const $list = $(this.listSelector); const $selectField = $list.parents(this.wrapperSelector).find(this.selectSelector); $selectField.find("option").slice(1).remove(); for (let idx = 2; idx <= $list.length; idx += 1) { $(`<option value="${idx}">${idx}</option>`).appendTo($selectField); } } }
Version data entries
44 entries across 44 versions & 1 rubygems