Open mikermcneil opened 12 years ago
Proper middleware is a better bet-- should come back to this as far as normalizing a reusable client-side router for running sails on the client as well at some point down the road @sgress454 what do you think?
FRAMEWORK.define('Toggle', function () {
return {
// Verify that the toggle is enabled
// if so, flip its active state,
// then prevent the event from bubbling up
click: [ 'checkEnabled', 'toggle', '.' ],
// If you return something falsey (or don't return), the chain ends
// otherwise, the middleware chain continues
checkEnabled: function () {
return ! this.disabled;
},
// Toggle the active class
// (all shorthand returns true)
toggle: '! .active'
};
});
There is logic that should be performed before every route, on on the very first route.
These should probably have a filesystem convention, whether that's to put them in a file in the /mast/routes directory or in the top level /mast dir.
Tentative spec:
Where
arguments*
are standard Backbone route arguments, e.g.:#/:arg1/:arg2
andfullRoute
is the complete route string.