Simple starting point for Ember.js fiddles

by pangratz666

HTML

<script src="https://github.com/downloads/emberjs/ember.js/ember-0.9.5.js"></script>
<script type="text/x-handlebars" >
    {{view App.UserTextField}}
    {{#each App.recentUsersArray.reverse}}
        <li>
            <a href="#" title="view again" {{action "searchAgain" target="App.recentUsersArray"}}>{{this}}</a>
        </li>
    {{/each}}
</script>

JavaScript

App = Ember.Application.create();

App.recentUsersArray = Em.ArrayController.create({
    content: ['a', 'b', 'c'],
    add: function(name){
        this.pushObject(name);
    },
    reverse: function(){
        return this.get('content').toArray().reverse();
    }.property('content.@each').cacheable(),
});

App.UserTextField = Ember.TextField.extend({
    insertNewline: function(){
        App.recentUsersArray.add(this.get('value'));
        this.set('value', '');
    }
});