I have a listener attached to page:afterout
that does some cleanup: removing a Backbone.js view and its $el, destroying infinite scroll, popovers etc. But, page:afterout
is triggered when you move both forwards and backwards, so I had to add logic in the page:afterout
listener as follows:
if (app.view.current.router.currentRoute.url == '/previous-page-path/' ) {
...do cleanup...
} else {
...don't do anything...
}
Is there a better way to do this? If I remember correctly, [v1] had a page:back
event, but I can’t find anything similar in [v2]
I know I could just load the page contents from scratch every time the page transitions into view, but I’d rather keep the data that I’ve loaded when the user moves forward, since they are very likely to go forwards and backwards frequently.