Sha256: a2fba5edb5041928e0c375a2b1818b86bcb44be5df7a2b454a68982d73243795
Contents?: true
Size: 1.23 KB
Versions: 4
Compression:
Stored size: 1.23 KB
Contents
export default class SelectWorkType { /** * Initializes the class in the context of an individual table element * @param {jQuery} element the table element that this class represents */ constructor(element) { this.$element = element; this.target = element.data('target') this.modal = $(this.target); this.form = this.modal.find('form.new-work-select') // launch the modal. element.on('click', (e) => { e.preventDefault(); this.modal.modal(); // ensure the type is set for the last clicked element this.type = element.data('create-type') // add custom routing logic when the modal is shown this.form.on('submit', this.routingLogic.bind(this)); }); // remove the routing logic when the modal is hidden this.modal.on('hide.bs.modal', (e) => { this.form.unbind('submit') }); } // when the form is submitted route to the correct location routingLogic(e) { e.preventDefault(); // get the destination from the data attribute of the selected radio button window.location.href = this.destination() } destination() { return this.form.find('input[type="radio"]:checked').data(this.type) } }
Version data entries
4 entries across 4 versions & 2 rubygems