Saturday, 31 August 2013

Rails 4 Turbolinks back button and multiple event binding because of pagesCached

Rails 4 Turbolinks back button and multiple event binding because of
pagesCached

I bind my events on $(document).on "page:change"... Example of event bind:
$('#groups').on 'click', 'div.group a.edit_group', Groups.edit_show. This
works fine with user clicking on links...
The problem occurs when user clicks back button and the forward button.
"page:change" triggers another event bind so now I have event binded twice
(which is a problem whit jquery toggle function). This double binding
occurs I guess because of pagesCached just loads cached DOM of the page
with already previously binded events on nodes.
I could disable pagesCached, but is there another solution?

No comments:

Post a Comment