Sha256: 36a791bad6b093c1131acada7aba3ca0b2abcf1b5d77fba3e17e322d9b787e8a
Contents?: true
Size: 1.29 KB
Versions: 5
Compression:
Stored size: 1.29 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() if (this.destination() === undefined) return false // 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
5 entries across 5 versions & 2 rubygems