我有一个这样的路由器设置:
var AppRouter = Backbone.Router.extend({
routes: {
"/agents/:id": "getAgent",
"/orders/:id": "getOrders",
"/users/:id": "getUsers",
'*path': 'defaultRoute'
},
getAgent: function(id) {
ticketList.url = "/index.php/tickets/viewJSON/a"+id;
},
getOrders: function(id) {
ticketList.url = "/index.php/tickets/viewJSON/o"+id;
},
getUsers: function(id) {
ticketList.url = "/index.php/tickets/viewJSON/u"+id;
},
defaultRoute: function() {
//(here needs to be the code)
}
});
我正在使用 codeigniter,所以当我访问时,/index.php/agents/view/1103
我需要强制ticketList.url
-/index.php/tickets/viewJSON/a1103
取自a
(/agent/
这将分别在user
、agent
和order
、和之间变化u
,然后从URL 部分的任何路径中获取 ID 。a
o
view
获取从 URL 获取这些参数的默认路由的最佳方法是什么?从字面上拆分document.URL?