Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : 'attributes' and extended models

$
0
0
I did the following to ensure the existence of the expected attributes on inheriting models:

can.Model('Person', {
   attributes: {
      id: 'string',
      phone_numbers: 'PhoneNumber.models'
   }
},{});

Person.extend('Programmer', {
   attributes: can.extend({
      computers: 'Computer.models'
   }, Person.attributes)
},{});

That is admittedly a bit of a hack, but it means my attributes from Person is now available on Programmer as well. Funny enough defaults appeared to be inherited...

My hope is that this reply will trigger a reply from someone with deeper knowledge who can either confirm the above method or show how it should be done :-)

Viewing all articles
Browse latest Browse all 3491

Trending Articles