javascript - No click event when rendering a js.erb partial -
what happens dom when re-render partial js.erb
? can no longer click events.
based on this tutorial, have followed re-render js.erb
partial works fine. when click "cat.name" button (on linked page), , on page button i'm listening click events not working.
the run down:
on index page, click event works. when make request from_category
, no more click event. happen?
html:
<button id="test" value="ok">click</button>
js:
$( "#test" ).on("click", function(e) { console.log(e.target.value) });
you click events don't bind new dom elements should use event delegation bubble events newly created dom elements
$('body').on('click input keypress','.the_dynamic_element',function(){ });
Comments
Post a Comment