logicPwn
logicPwn

Reputation: 103

How to stop Senna.js from calling multiple jQuery event handlers

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?

Upvotes: 1

Views: 312

Answers (1)

user2551403
user2551403

Reputation: 66

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
});

Upvotes: 2

Related Questions