Created
July 17, 2013 17:10
-
-
Save dlai0001/6022486 to your computer and use it in GitHub Desktop.
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
App = Ember.Application.create(); | |
App.Router.map(function() { | |
// put your routes here | |
}); | |
App.Store = DS.Store.extend({ | |
adapter: DS.FixtureAdapter.create() | |
}); | |
App.IndexRoute = Ember.Route.extend({ | |
model: function() { | |
return App.Person.find(); | |
} | |
}); | |
App.IndexController = Ember.ArrayController.extend({ | |
itemSelected: function(item) { | |
console.log("clicked on:", item.get('fullName')); | |
item.set('isSelected', !item.get('isSelected')); | |
}, | |
sortProperties: ['rank'], | |
sortAscending: true | |
}); | |
App.Person = DS.Model.extend({ | |
firstName: DS.attr('string'), | |
lastName: DS.attr('string'), | |
birthday: DS.attr('date'), | |
isSelected: DS.attr('boolean'), | |
rank: DS.attr('number'), | |
fullName: function() { | |
return this.get('firstName') + ' ' + this.get('lastName'); | |
}.property('firstName', 'lastName') | |
}); | |
App.Person.FIXTURES = [ | |
{ id: 1, firstName: 'Trek', lastName: 'Glowacki', rank:0 }, | |
{ id: 2, firstName: 'Bob', lastName: 'Sanders', rank:2 }, | |
{ id: 3, firstName: 'George', lastName: 'Thompson', rank:3 }, | |
{ id: 4, firstName: 'Scott', lastName: 'McKinly', rank:4 }, | |
{ id: 5, firstName: 'Albert', lastName: 'Einstein', rank:5 }, | |
{ id: 6, firstName: 'Tom' , lastName: 'Dale', rank:1 } | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Corresponding index file. (used with EmberStarterKit and EmberData)
<title>Ember Starter Kit</title> <script type="text/x-handlebars">Selenium Tech Demo
``` {{outlet}} ``` </script> <script type="text/x-handlebars" data-template-name="index">{{#each item in model}} {{#if item.isSelected}}- {{item.fullName}}
{{else}}
- {{item.fullName}}
{{/if}}
{{/each}}
</script> <script src="js/libs/jquery-1.9.1.js"></script> <script src="js/libs/handlebars-1.0.0-rc.4.js"></script> <script src="js/libs/ember-1.0.0-rc.6.js"></script> <script src="js/libs/emberdata.js"></script> <script src="js/app.js"></script>