So I have a user model, and a user can have friends, the friends are
also user models.
What I want to do is use the define plugin to set the 'friends' attribute to be a model.List of user models, something like:
What I want to do is use the define plugin to set the 'friends' attribute to be a model.List of user models, something like:
steal(
'can/map/define',
function(define) {
return can.Model.extend(
// Static
{
// Static methods here
},
//Prototype
{
define: {
friends:{
set:function(newFriends){
return new userModel.List(newFriends.attr());
}
} }
});
so then i can get the friends and set them like:
fetchUserFriends:function(){
var self = this;
this.displayedUser.getFriends()
.done(function (friends) {
self.displayedUser.attr('friends', friends);
})
.fail(function(resp){
});
}
and i can then use my user model methods on the users friends.
The problem being I dont know how to set the model list in the first step, any thoughts?
The problem being I dont know how to set the model list in the first step, any thoughts?