Skip to content

Instantly share code, notes, and snippets.

@trek
Forked from tomchiverton/app.js
Created August 15, 2012 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save trek/3359699 to your computer and use it in GitHub Desktop.
Save trek/3359699 to your computer and use it in GitHub Desktop.
EmberJS list control that can tell what was clicked
EvEditor = Em.Application.create({
main: { componentList:[{name:'a'},{name:'b'},{name:'c'}]
});
EvEditor.ApplicationController = Em.Controller.extend()
EvEditor.ApplicationView = Em.View.extend({
templateName: 'application'
});
EvEditor.ComponentListController = Ember.ArrayController.extend({
removeItem: function(event){
this.removeObject(event.context);
};
});
EvEditor.ComponentListView = Ember.View.extend({
templateName: 'component-list'
});
EvEditor.Router = Em.Router.extend({
root: Ember.Route.extend({
index: Ember.Route.extend({
route: '/',
connectOutlets: function(router){
router.get('applicationController').connectOutlet('componentList', EvEditor.get('main'componentList'))
}
})
})
});
EvEditor.initialize()
<p>
select an editable area of the message to edit it or select a new item from the list below to insert
{{outlet}}
</p>
<ul>
{{#each item in controller}}
<li>
<button {{action removeItem item target="controller"}}>{{item.name}}</button>
</li>
{{/each}}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment