Backbone fetch() always returns same model
For some reason, my code is always returning the same model even though I
can see that the correct id is being passed in after I select the item in
a listView page.
// main.js (relavent function)
venueDetails: function (id) {
// here, id is correct
var venue = new Venue({_id: id});
venue.fetch({success: function(){
// here, the id of venue is changed for some reason
console.log(venue.id);
$("#content").html(new VenueView({model: venue}).el);
}});
this.headerView.selectMenuItem();
},
The model,
// model.js (relavent model)
var base = 'http://localhost:3000';
window.Venue = Backbone.Model.extend({
urlRoot: base+"/venues",
idAttribute: "_id",
});
window.VenueCollection = Backbone.Collection.extend({
model: Venue,
url: base+"/venues?populate=true"
});
In the picture, you can see where the model.id is different from whats in
the url
No comments:
Post a Comment