Created
May 25, 2011 05:14
-
-
Save ericf/990385 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var FooModel = Y.Base.create('fooModel', Y.Model, [], { | |
| idAttribute : 'uid' | |
| }, { | |
| ATTRS : { | |
| uid : {} | |
| foo : {} | |
| } | |
| }); | |
| var foo = new FooModel({ uid: '1', foo: 'foo' }); | |
| foo.get('id') === '1' // => true | |
| foo.get('uid') === '1' // => false? it became `undefined` | |
| // calling `attrHost.get()` ends up calling `attrHost.set()` under the hood. | |
| // we change the behavior of `set` operations to keep `id` and a custom idAttribute in sync. | |
| // with our fix to `_getAttrInitVal`: | |
| foo.get('id') === foo.get('uid') // => true | |
| // and the order these are `get`-ed doesn't matter: | |
| foo.get('uid') === foo.get('id') // => true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment