From c66a8dc87865e2bdd470e9ebbd21abee389c6564 Mon Sep 17 00:00:00 2001 From: Steven Devijver Date: Tue, 19 Mar 2013 20:37:40 +0100 Subject: [PATCH] Changed form_values.cljs: remove existing event listeners before registering new event listener --- src/webfui/plugin/form_values.cljs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/webfui/plugin/form_values.cljs b/src/webfui/plugin/form_values.cljs index e2fe523..480ee06 100644 --- a/src/webfui/plugin/form_values.cljs +++ b/src/webfui/plugin/form_values.cljs @@ -15,10 +15,16 @@ value))] (event element new-element))))) +(def eventListeners (atom [])) + (deftype form-values [] Plugin - (declare-events [this body dom-watchers parsed-html] - (.addEventListener body "input" (partial input dom-watchers parsed-html))) + (declare-events + [this body dom-watchers parsed-html] + (doseq [e @eventListeners] (.removeEventListener body "input" e false)) + (let [eventListener (partial input dom-watchers parsed-html)] + (.addEventListener body "input" eventListener false) + (swap! eventListeners conj eventListener))) (fix-dom [this] nil))