-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Execution order of Matched Routes Question #13
Comments
the execution is based on the you can use a function to validate the route if you need to check something before dispatching the var route1 = crossroads.addRoute('/news/{id}');
route1.rules = {
id : function(value, request, valuesObj){
return isUserAuthenticated(); //if false it won't match route
}
}; using the function to validate is probably the recommended approach since you can't ensure a specific listener will always be the first one to be called (you can add another listener with a higher priority later that will get executed before) currently the rules object doesn't have any "magic" property that validates the whole route, maybe I should add it for cases where you don't have any "{variable}" but still need to do some kind of validation based on the application estate.. - I created a new issue (#14) for it. you can find more info about how to use the Route.rules on the documentation. cheers. |
Thanks man, this looks awesome and is exactly what I need! I saw it in JavaScript Weekly. Good work! Integrating into my project.... now! |
Could you validate off the section? Seems like a feasible interim solution until you get your magic property in.
|
the validation function should return route1.rules = {
section : function(value, request, valuesObj){
return (isUserAuthenticated() && value == "news");
}
}; example above will validate only if user is authenticated and section fragment is "news". |
In your example below,
The text was updated successfully, but these errors were encountered: