Skip to content

Instantly share code, notes, and snippets.

@tomchiverton
Created August 15, 2012 09:47
Show Gist options
  • Save tomchiverton/3358235 to your computer and use it in GitHub Desktop.
Save tomchiverton/3358235 to your computer and use it in GitHub Desktop.
EmberJS list control that can tell what was clicked
window.EvEditor=Em.Application.create({
VERSION: "0.0.2",
main:{ componentList:[{name:'a'},{name:'b'},{name:'c'}],
ComponentView : Em.View.extend({
tagName: 'li',
removeItem: function() {
var component = this.get('component');
alert(component.name);
}
})
}
});
editView=Em.View.create({
templateName: "main"
});
editView.appendTo($('#adiv'));
<p>
select an editable area of the message to edit it or select a new item from the list below to insert
<ul>
{{#each EvEditor.main.componentList}}
{{#view EvEditor.main.ComponentView componentBinding="this"}}
<button {{action removeItem}}>
{{view.component.name}}</button>
{{/view}}
{{/each}}
</ul>
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment