Skip to content

Instantly share code, notes, and snippets.

@tim-evans
Created July 1, 2011 17:48
Show Gist options
  • Select an option

  • Save tim-evans/1059059 to your computer and use it in GitHub Desktop.

Select an option

Save tim-evans/1059059 to your computer and use it in GitHub Desktop.
RecordArray + ArrayController = :(
MyApp = {};
MyApp.store = SC.Store.create();
MyApp.Thing = SC.Record.extend({
primaryKey: 'name',
name: SC.Record.attr(String)
});
MyApp.thingController = SC.ArrayController.create({
content: MyApp.store.find(SC.Query.local(MyApp.Thing))
});
MyApp.ListView = SC.ListView.extend({
contentBinding: 'MyApp.thingController.arrangedObjects',
exampleView: SC.TemplateView.extend({
template: SC.Handlebars.compile("{{content.name}}")
})
});
MyApp.mainPane = SC.MainPane.create();
MyApp.mainPane.appendChild(MyApp.ListView.create());
MyApp.mainPane.append();
// Later do:
MyApp.store.loadRecords(MyApp.Thing, [{ name: "Thing 1" },
{ name: "Thing 2" }]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment