Skip to content

Instantly share code, notes, and snippets.

@gfranko gfranko/example.js
Last active Dec 19, 2015

Embed
What would you like to do?
Ember.js Views - It would be amazing if Ember Views would allow you to pass an events object of key/value event delegation mappings (similar to Backbone Views). Right now you have to use event.target conditional checking, create more granular Views, or use the action Handlebars helper to trigger custom events.
App = Ember.Application.create();
App.ExampleView = Ember.View.extend({
// This removes the whole event.target ugly checking
events: {
'.example click': function() {
console.log('an example image was clicked!');
}
}
});
<script type="text/x-handlebars" data-template-name="example">
{{#view App.ExampleView}}
<div class="main-container">
<h2>Pick Your Character:</h2>
<div class="row-fluid">
<div class="container">
<img src="./imgs/someImage.png" class="example">
</div>
<div class="container">
<img src="./imgs/someImage.png" class="example">
</div>
</div>
</div>
{{/view}}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.