Prevent modals from firing multiple events

- e.g. if the modal has been open and closed multiple times!
- Detach all previously attached events
This commit is contained in:
Oliver 2018-05-07 23:46:41 +10:00
parent fdf214626c
commit ee0c664d28

View File

@ -125,6 +125,9 @@ function launchDeleteForm(modal, url, options = {}) {
}
});
// Un-bind any attached click listeners
$(modal).off('click', '#modal-form-delete');
$(modal).on('click', '#modal-form-delete', function() {
var form = $(modal).find('#delete-form');
@ -169,6 +172,9 @@ function handleModalForm(modal, url, options) {
return false;
});
// Un-bind any attached click listeners
$(modal).off('click', '#modal-form-submit');
$(modal).on('click', '#modal-form-submit', function() {
$(modal).find('.js-modal-form').ajaxSubmit({
url: url,