Created
August 17, 2012 08:54
-
-
Save viteinfinite/3377131 to your computer and use it in GitHub Desktop.
FIXED: Flame on! A beginner's guide to Ember.js
This file contains 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.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') | |
}); |
This file contains 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
<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