Skip to content

Instantly share code, notes, and snippets.

@gfranko
Last active December 19, 2015 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save gfranko/6029434 to your computer and use it in GitHub Desktop.
Save gfranko/6029434 to your computer and use it in GitHub Desktop.
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