Skip to content

Instantly share code, notes, and snippets.

@gfranko
Last active December 19, 2015 22:39
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
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