summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-02-17 09:24:47 +0100
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-02-17 09:24:47 +0100
commit594cdbbe36881f31b2bd7c9da49f8b42be3f6683 (patch)
tree2bf5bf335ee210aa46a3f0b7c57aff2653c41a83
parent50fcb0634c9ebe894988103184d50d372bc76907 (diff)
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.
-rw-r--r--src/scripts/controllers/simulationcontroller.ts6
1 files changed, 5 insertions, 1 deletions
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();