UNPKG

650 BJavaScriptView Raw
1var _ = require("underscore");
2var EventedClass = require("../EventedClass.js");
3
4module.exports = EventedClass.extend("Controller", {
5
6 bindRoutes: function(app){
7 for(var key in this.routes){
8 var handlerName = this.routes[key];
9 if(Array.isArray(handlerName)){
10 for(var i=0;i<handlerName.length;i++){
11 if(_.isFunction(this[handlerName[i]])){
12 app.router.on("route:"+key, this[handlerName[i]], this);
13 }
14 }
15 }
16 else{
17 if(_.isFunction(this[handlerName])){
18 app.router.on("route:"+key, this[handlerName], this);
19 }
20 }
21 }
22 }
23});