From ee0c664d28490fc3978c277c7299822c89e83339 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 7 May 2018 23:46:41 +1000 Subject: [PATCH] Prevent modals from firing multiple events - e.g. if the modal has been open and closed multiple times! - Detach all previously attached events --- InvenTree/static/script/modal_form.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/InvenTree/static/script/modal_form.js b/InvenTree/static/script/modal_form.js index e87af2467a..ea67abe4f7 100644 --- a/InvenTree/static/script/modal_form.js +++ b/InvenTree/static/script/modal_form.js @@ -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,