Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update template destroys event handlers #16

Open
avescodes opened this issue Feb 14, 2014 · 0 comments
Open

update template destroys event handlers #16

avescodes opened this issue Feb 14, 2014 · 0 comments
Labels

Comments

@avescodes
Copy link

io.pedestal.app.render.push.templates/update-template uses dom/set-html! to re-render its data. This is a problem if you have previously placed event listeners on the html element that was previously there, it gets wiped out.

[domina :as dom]
[domina.css :as dc]
[domina.events :as de]

(de/listen! (dc/sel "h1") :dblclick 
     (fn [e] (dom/set-html! (dc/sel "#stuff") "I am new html")))
(de/listen! (dom/by-id "stuff") :dblclick 
      (fn [e] (.log js/console "I was clicked on")))
<h1>Header</h1>
<div id="stuff">Click on me</div>

You can use the event handler for #stuff until you double click the header, then it will wipe out #stuff. It no longer responds to double click events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant