骨干路由器路径设置

时间:2013-04-29 19:03:17

标签: javascript backbone.js backbone-routing

我为我的骨干路由器配置了路径

var myApp = myApp || {};

myApp.router = Backbone.Router.extend({

   routes:{
      "somecontent_:id": "content",
      "":"defaultPath"
  },

  defaultPath: function(){
     //default path 
  },

  content: function(id){
     console.log("some new id"+id);
   }
});

myApp.newRouter = new myApp.router();

我的默认路径看起来像[0]和新路径[1]

[0]myurl.com/somecontent
[1]myurl.com/somecontent_id

问题:“somecontent_:id”不对/有问题,所以“内容”方法也没有被调用。

提前感谢任何建议/建议

编辑1:

我错误地提到了我的道路。它应该是

[0]myurl.com/somecontent/one/two
[1]myurl.com/somecontent/one/two#newcontent_id

我从视图中调用那些路由器

myApp.newRouter.navigate("",true) for [0]
myApp.newRouter.navigate("/newcontent_"+ id, true); for [1]

0 个答案:

没有答案