Created
August 15, 2012 09:47
-
-
Save tomchiverton/3358235 to your computer and use it in GitHub Desktop.
EmberJS list control that can tell what was clicked
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
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')); |
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
<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