Answer the question
In order to leave comments, you need to log in
Backbone - how to change Model in Collection?
There is a simple model and collection:
MG.Models.User = Backbone.Model.extend({
defaults: {
firstname: '',
nickname: '',
lastname: '',
_id:''
},
urlRoot:"/users",
idAttribute: "_id"
});
MG.Collections.Users = new (Backbone.Collection.extend({
model: MG.Models.User,
url:"/users",
idAttribute: "_id"
}))();
MG.Views.User = Backbone.Marionette.ItemView.extend({
template: "#template-user"
});
MG.Layout.content.show(new MG.Views.User({
model: MG.Collections.Users.findWhere({_id:"номер юзера"})
}));
setTimeout(function(){
MG.Collections.Users.findWhere({_id:"номер юзера"}).fetch();
},10000);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question