Skip to content

Instantly share code, notes, and snippets.

@viteinfinite
Created August 17, 2012 08:54
Show Gist options
  • Save viteinfinite/3377131 to your computer and use it in GitHub Desktop.
Save viteinfinite/3377131 to your computer and use it in GitHub Desktop.
FIXED: Flame on! A beginner's guide to Ember.js
App.recentUsersController = Em.ArrayController.create({
content: [],
addUser: function(name) {
if ( this.contains(name) ) {
this.removeObject(name);
}
this.pushObject(name);
},
removeUser: function(event){
this.removeObject(event.context);
},
searchAgain: function(event){
App.tweetsController.set('username', event.context);
App.tweetsController.loadTweets();
},
reverse: function(){
return this.toArray().reverse();
}.property('@each')
});
<h3>Recent Users</h3>
<ol>
{{#each user in App.recentUsersController.reverse}}
<li>
<a href="#" title="view again" {{action "searchAgain" "user" target="App.recentUsersController"}}>{{user}}</a> -
<a href="#" title="remove" {{action "removeUser" "user" target="App.recentUsersController"}}>X</a>
</li>
{{/each}}
</ol>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment