Created
April 19, 2011 13:36
-
-
Save jfahrenkrug/927722 to your computer and use it in GitHub Desktop.
SC.ManyArray elements can't be accessed with getPath
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
TP.MATest = SC.Record.extend({ | |
}); | |
TP.store.createRecord(TP.MATest, {name: 'Thing One'}); | |
TP.store.createRecord(TP.MATest, {name: 'Thing Two'}); | |
function manyArrayTest() { | |
// arrays | |
a1 = ['a', 'b', ['c', 'd']]; | |
a2 = ['x', ['y', ['z']]]; | |
// array Controllers | |
ac1 = SC.ArrayController.create({content: a1}); | |
ac2 = SC.ArrayController.create({content: SC.ArrayController.create({content: a2})}); | |
ac3 = SC.ArrayController.create({content: TP.store.find(TP.MATest)}); | |
// root | |
root = SC.ArrayController.create({content: [ac1, ac2, ac3, a1, a2]}); | |
// tests | |
SC.Logger.log('content', root.getPath('content')); | |
SC.Logger.log('content.0', root.getPath('content.0')); | |
SC.Logger.log('content.3', root.getPath('content.3')); | |
SC.Logger.log('content.0.0', root.getPath('content.0.0')); | |
SC.Logger.log('content.3.0', root.getPath('content.3.0')); | |
SC.Logger.log('content.0.content.0', root.getPath('content.0.content.0')); | |
SC.Logger.log('Now with SC.ManyArray...'); | |
SC.Logger.log('content.2', root.getPath('content.2')); | |
// Can't access the first element of the SC.ManyArray with getPath... | |
SC.Logger.log('content.2.0', root.getPath('content.2.0')); | |
SC.Logger.log('But: getPath("content.2").getEach("name")', root.getPath("content.2").getEach("name")); | |
SC.Logger.log('But: getPath("content.2").firstObject().get("name")', root.getPath("content.2").firstObject().get("name")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment