我的路线设置如下:
var AppRouter = Backbone.Router.extend({
routes: {
"items": "getItems", // matches http://example.com/#anything-here
"/*": "showAll",
"edit/:id" : "editItem",
"save/:id" : "saveItem",
"delete/:id" : "deleteItem"
}
});
// Initiate the router
var app_router = new AppRouter;
app_router.on('route:getItems', function() {
});
app_router.on('route:showAll', function(){
console.log("SHOWALL");
skillsview.render();
});
app_router.on('route:editItem', function(id){
console.log("EDIT SKILL: "+id);
editview.render(id);
});
app_router.on('route:saveItem', function(id){
console.log("SAVED SKILL");
skillsview.render(id);
});
app_router.on('route:deleteItem', function(id){
console.log("DELETED SKILL");
skillsview.render(id);
});
但是,当我尝试将id变量发送到我的渲染函数时,我收到了前端JS错误。渲染函数不想采用我认为的任何参数。但如果这是真的,我如何将我的路由器参数发送到我的渲染函数,在那里我使用路由器提供的id获取模型?