Browse files

fix

  • Loading branch information...
1 parent ac3503c commit 1f3b181636fa061b0e21f4ecfc15a2a50f714183 @RubyLouvre committed May 28, 2013
Showing with 8 additions and 5 deletions.
  1. +8 −5 avalon.router.js
View
13 avalon.router.js
@@ -322,13 +322,16 @@ new function() {
return result;
}
};
- var callbacks = {};
- var router = new Router();
+ var callbacks = {}, errback, router = new Router();
avalon.Router = {
extend: function(obj) {//定义所有路由规则
if (typeof obj.routes === "object") {
for (var i in obj.routes) {
- router.add("GET", i, obj.routes[i]);
+ if(i === "*error"){
+ errback = obj.routes[i]
+ }else{
+ router.add("GET", i, obj.routes[i]);
+ }
}
}
for (var i in obj) {
@@ -345,8 +348,8 @@ new function() {
return callbacks[key].apply(match, match.args);
}
}
- if (typeof callbacks["*error"] === "function") {
- callbacks["*error"](url);
+ if (typeof callbacks[errback] === "function") {
+ callbacks[errback](url);
}
}
};

0 comments on commit 1f3b181

Please sign in to comment.