1

I have developed a SPA website using Senna.js and it works great! However, I have recently noticed that it doesn't remove jQuery event handlers when leaving the page. So I have all kinds of functions firing twice when I navigate back to a page I have already visited.

I fixed most of my personal code by doing this

$("#element").off("event").on("event", etc.)

But there are thousands of lines of other people's code which is also powering my website and I am worried that they are firing twice as well.

Does anybody on SO have any insight or approaches to handling this?

logicPwn
  • 103
  • 1
  • 8

1 Answers1

2

You can detach event handlers using Senna's lifecycle events. For example:

var app = new senna.App();

app.on('beforeNavigate', function() {
// detach jQuery event handlers
});