Skip to content
Permalink
Browse files

Issue #1 Resolution - stacking submit event listeners

Prevent adding multiple event listeners on "submit" for each reload.
This was causing n new events when add button pressed
  • Loading branch information...
tkjone committed Sep 23, 2019
1 parent b26c1aa commit ceb1ae2b907eb8c04befcb30c21e9bab81706000
Showing with 11 additions and 4 deletions.
  1. +11 −4 src/demo_reloadable_code/calendar.cljs
@@ -165,16 +165,23 @@

; Register event listeners

(events/listen
(.. js/document (querySelector ".calendar-form"))
"submit"
handle-add-event!)
(defn ^:before-load teardown []
(events/removeAll
(.querySelector js/document ".calendar-form")))


(defn ^:after-load setup []
(events/listen
(.. js/document (querySelector ".calendar-form"))
"submit"
handle-add-event!))

(events/listen
(.. js/document (querySelector "#event_start"))
"change"
update-event-end-dropdown!)

(defonce initial-load (setup))

;; Init

0 comments on commit ceb1ae2

Please sign in to comment.
You can’t perform that action at this time.