Created
November 3, 2011 09:42
Revisions
-
Theo Cushion created this gist
Nov 3, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ // Models HTH.Project = SC.Record.extend({ title: SC.Record.attr(String), tasks: SC.Record.toMany('HTH.Task',{ isMaster: YES, inverse: 'project' }) }); HTH.Task = SC.Record.extend({ title: SC.Record.attr(String), project: SC.Record.toOne('HTH.Project', { isMaster: NO }) }); HTH.Project.FIXTURES = [ { guid: 1, title: 'Send man to moon', tasks: [1,2]}, { guid: 2, title: 'Master handstand', tasks: [3]}]; HTH.Task.FIXTURES = [ { guid: 1, title: 'Find rocket', project: 1}, { guid: 2, title: 'Find fuel', project: 1}, { guid: 3, title: 'Stand on hands', project: 2}]; HTH.store = SC.Store.create().from(SC.Record.fixtures); // Controllers HTH.projectsController = SC.ArrayProxy.create({ content: HTH.store.find(HTH.Project) }); 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ // Update Project HTH.store.find(HTH.Project).get('firstObject').set('title','Updated the title!'); // Update Task HTH.store.find(HTH.Task).get('firstObject').set('title','Updated the title!'); // Create Project project = HTH.store.createRecord(HTH.Project, {title: "New" }); // Add Task to project (can't get working) var task = HTH.store.createRecord(HTH.Task, {title: "New task" }); project.get('tasks').pushObject(task); 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ <script type="text/x-handlebars"> {{#collection contentBinding="HTH.projectsController.content"}} <h3>{{content.title}}</h3> {{#collection contentBinding="content.tasks"}} <span>{{content.title}}</span> {{/collection}} {{/collection}} </script>