Skip to content

Instantly share code, notes, and snippets.

@johanvalcoog
Forked from zackdouglas/app
Created January 11, 2012 20:16
Show Gist options
  • Save johanvalcoog/1596554 to your computer and use it in GitHub Desktop.
Save johanvalcoog/1596554 to your computer and use it in GitHub Desktop.
Test = SC.Application.create({ NAMESPACE: 'Test', VERSION: '0.1.0', store: SC.Store.create().from(SC.Record.fixtures) }) ;
Test.Top = SC.Record.extend({
middles: SC.Record.toMany(
SC.Record.extend({
bottoms: SC.Record.toMany(
SC.Record,
{
isNested: YES,
isMaster: NO
}
)
}),
{
isNested: YES,
isMaster: NO
}
)
});
Test.TopObjectController = SC.ObjectController.create({
contentObserver: function () {
console.debug(this.get('content'));
}.observes('content')
});
Test.MiddlesArrayController = SC.ArrayController.create({
isEditable: YES,
contentBinding: 'Test.TopObjectController.middles'
});
top = Test.Top.create({ middles: [] });
Test.TopObjectController.set('content', top);
newMiddle = SC.copy({ bottoms: [] });
newMiddle._proxy = window.examplePointer = SC.ArrayController.create({
contentBinding: SC.Binding.from('bottoms', newMiddle)
});
Test.SubsArrayController.addObject( newMiddle );
window.examplePointer.addObject( SC.copy({}) );
Test.TopView = SC.View.design({
childViews: ['middles'],
middles: SC.ListView.design({
contentBinding: 'Test.MiddlesArrayController.arrangedObjects',
exampleView: SC.View.design({
render: function () {
sc_super();
this.set('controller',
SC.ArrayController.create({
content: this.getPath('content.bottoms')
})
);
},
childViews: ['bottoms'],
bottoms: SC.ListView.design({
contentBinding: '.parentView.controller',
exampleView: SC.TextFieldView.design({
contentBinding: '.content.myField'
})
})
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment