In a separate view in backbone I have a function that basically creates a new post:
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
},
In another view all the views are listed, and if the user clicks one of these views the uri changes to "#post/:id"
and in my roots I have this:
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);
},
I am having no problem to navigate to any of these posts from this list of posts, my router handles them very well, but I am having a problem navigating to the post that I just created after creating possibly inside the save
function..