Skip to content

Instantly share code, notes, and snippets.

@ericf
Created May 25, 2011 05:14
Show Gist options
  • Select an option

  • Save ericf/990385 to your computer and use it in GitHub Desktop.

Select an option

Save ericf/990385 to your computer and use it in GitHub Desktop.
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