Hi there!
I'm a user of JSMVC v.3.2, and I work on a project that has, among others, this type of architecture:
//--Begin
Model.extend('CareGiver', {}, {
model: function(data) {
this.name = data.name;
this.surname = data.surname;
},
getFullName: function() {
return this.name + ", " + this.surname;
}})
Model.extend('Animal', {}, {
model: function(data) {
this.color = data.color;
this.careGiver = App.Models.CareGiver.model(data.careGiver);
}})
Animal.extend('Bear', {},
model: function(data) {
var aBear = this._super(data);
aBear.location = data.location;
aBear.name = aBear.careGiver.getFullName() + ' Bear';
}})
//--End
The previous code works very well for Bear findOne, findAll. But when I try to take advantage of 'attributes' feature
Model.extend.('Animal', {
attributes: {
careGiver: 'App.Models.CareGiver.model'
}}, {
...
}})
Animal.extend('Bear', {
attributes: {
careGiver: 'App.Models.CareGiver.model'
}}, {
...
}})
on findOne/findAll, in Bear model aBear.careGiver is still an Object when trying to call getFullName() so I get an error on Bear's model.
I need some hints on make it work. Thanks in advance.
I'm a user of JSMVC v.3.2, and I work on a project that has, among others, this type of architecture:
//--Begin
Model.extend('CareGiver', {}, {
model: function(data) {
this.name = data.name;
this.surname = data.surname;
},
getFullName: function() {
return this.name + ", " + this.surname;
}})
Model.extend('Animal', {}, {
model: function(data) {
this.color = data.color;
this.careGiver = App.Models.CareGiver.model(data.careGiver);
}})
Animal.extend('Bear', {},
model: function(data) {
var aBear = this._super(data);
aBear.location = data.location;
aBear.name = aBear.careGiver.getFullName() + ' Bear';
}})
//--End
The previous code works very well for Bear findOne, findAll. But when I try to take advantage of 'attributes' feature
Model.extend.('Animal', {
attributes: {
careGiver: 'App.Models.CareGiver.model'
}}, {
...
}})
Animal.extend('Bear', {
attributes: {
careGiver: 'App.Models.CareGiver.model'
}}, {
...
}})
on findOne/findAll, in Bear model aBear.careGiver is still an Object when trying to call getFullName() so I get an error on Bear's model.
I need some hints on make it work. Thanks in advance.