before and after filter support for backbone.js
JavaScript
Pull request Compare This branch is 6 commits ahead, 2 commits behind angelo0000:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
backbone_filters.js

README.md

_Disclaimer: This fork has been updated to work with Backbone 0.9.2

Usage

Include backbone_filters.js after Backbone.

In your router you can now add:

before: {
    '^clerks' : function( args , regexpResult ) {
        /* do stuff to all routes starting with 'clerks' */
        /* return deferred resolved when before filter applied , reject deferred to alter execution */
        /* regexpResult Match found on your regexp*/
    },
    'another reg ex' : function() { }
}

If a before filter deferred is rejected, the action in the Router will not be called. Your filters will receive the same arguments that get passed to the actions.