From 594cdbbe36881f31b2bd7c9da49f8b42be3f6683 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Fri, 17 Feb 2017 09:24:47 +0100 Subject: Fix button handler being triggered multiple times The issue was that previous event handlers of the same button were not removed on closing the dialog. This is now resolved by removing all event handlers of the 'new experiment' button when registering a new handler. --- src/scripts/controllers/simulationcontroller.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/scripts/controllers/simulationcontroller.ts b/src/scripts/controllers/simulationcontroller.ts index bb46575c..2652d5d4 100644 --- a/src/scripts/controllers/simulationcontroller.ts +++ b/src/scripts/controllers/simulationcontroller.ts @@ -297,7 +297,11 @@ export class SimulationController { }); }); - $("#new-experiment-btn").click(() => { + let newExperimentBtn = $("#new-experiment-btn"); + // Remove previously added event handlers + newExperimentBtn.off(); + + newExperimentBtn.click(() => { const nameInput = $("#new-experiment-name-input"); if (nameInput.val() === "") { $(".experiment-name-alert").show(); -- cgit v1.2.3