Last active
December 19, 2015 22:39
-
-
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.
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
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!'); | |
} | |
} | |
}); |
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
<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