如何将参数传递给Backbone中的另一个页面?

时间:2014-07-25 11:52:33

标签: javascript backbone.js routes

如何将参数传递给Backbone中的另一个页面?

我将Backbone用于navigate到group_edit.html,我想将 id 传递给group_edit.html。

e.g

var routes = {};
routes[AD.page + '/edit/:_id']   = 'act_edit_group';    

act_edit_group: function(id) {  
    var t = this;            

    t.navigate("#ajax/group_edit.html", {
        trigger: true
    });
}        

但我无法在group_edit.html中获得 id

感谢。

1 个答案:

答案 0 :(得分:1)

这样。

routes: {
    "test/:id":"home"   
  },

  home: function(id) {         
      console.log(id); 
      // "1"
  }

如果您传递此URL(localhost .... #test / 1),将触发此路由

希望有所帮助