0

我有这样的路线设置:

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 获取模型?

4

0 回答 0