獲取數據我有一個路由器的設置,像這樣:Backbone.js的 - 默認路由器,從URL
var AppRouter = Backbone.Router.extend({
routes: {
"/agents/:id": "getAgent",
"/orders/:id": "getOrders",
"https://stackoverflow.com/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)
}
});
我用笨,所以當我訪問/index.php/agents/view/1103
我需要強制ticketList.url
是/index.php/tickets/viewJSON/a1103
- 所述a
從/agent/
採取(這將分別user
,agent
和order
,u
,a
和o
之間改變,然後從任何所採取的ID落後於URL的view
部分。
什麼是獲取默認路由從URL中獲取這些參數的最佳方式?從字面上拆分document.URL?
默認的URL是什麼? – 2012-08-01 18:43:33
看到我對下面的答案的評論,希望清除一些東西 – rickyduck 2012-08-02 08:04:57