【发布时间】:2013-08-02 22:30:52
【问题描述】:
在主干的单独视图中,我有一个基本上创建新帖子的功能:
save : function(){
console.log($('#big-input').val());
console.log(window.id);
this.collection.create({
name: $('#big-input').val(),
adress: $('small-input').val(),
postedBy: window.id
});
//navigate to that post
},
在另一个视图中列出了所有视图,如果用户单击其中一个视图,则 uri 将更改为“#post/:id”
在我的根上,我有这个:
routes: {
"" : "showForm",
"post/:id" : "showPost"
},
showPost: function(id){
var curmodel = this.collection.get(id);
console.log(curmodel);
var posts = new postView({model:curmodel});
posts.render();
$(".maincontainer").html(posts.el);
},
我从这个帖子列表导航到任何这些帖子都没有问题,我的路由器处理得很好,但是我在导航到我可能在 save 内创建后刚刚创建的帖子时遇到了问题功能..
【问题讨论】:
标签: javascript backbone.js backbone-routing