Skip to content

Instantly share code, notes, and snippets.

@dlai0001
Created July 17, 2013 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlai0001/6022486 to your computer and use it in GitHub Desktop.
Save dlai0001/6022486 to your computer and use it in GitHub Desktop.
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 }
];
@dlai0001
Copy link
Author

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment