PlankTon
PlankTon

Reputation: 12605

Backbone routes: Before & after hooks?

I'm trying to add the equivalent of rails' "flash" functionality in my backbone app, part of which involves putting a showFlash() at the top of each route in my router, and a purgeFlash() at the bottom.

Needless to say, adding those two methods to every route works, but it isn't the most elegant approach. Still, I'm struggling to figure out how to add hooks to backbone routers.

In short, I'd like to run showFlash() before navigating to any new page, and purgeFlash() afterwards. ...Any thoughts?

Upvotes: 3

Views: 495

Answers (1)

roberkules
roberkules

Reputation: 6605

This plugin should do the trick:

https://github.com/angelo0000/backbone_filters

(not sure though if it works with the latest backbone version)

update - according to this comment it works with 0.9.2

Upvotes: 2

Related Questions