Skip to content

Instantly share code, notes, and snippets.

@davidsteinberger
Last active November 9, 2015 23:02
Show Gist options
  • Save davidsteinberger/0b31c2ac3f1c74c66b8c to your computer and use it in GitHub Desktop.
Save davidsteinberger/0b31c2ac3f1c74c66b8c to your computer and use it in GitHub Desktop.
Closure action bubbling?
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
messages: null,
init() {
this.messages = [];
},
actions: {
parentClick() {
console.log('parentClicked');
this.get('messages').pushObject('parentClicked');
},
childClick(ev) {
//ev.stopPropagation(); // <<< remove comment to change
console.log('childClicked');
this.get('messages').pushObject('childClicked');
}
}
});
<h1>Welcome to {{appName}}</h1>
<div onClick={{action "parentClick"}}>
<input type="button" value="Parent">
<div>
<input type="button" value="Child" onClick={{action "childClick"}}>
</div>
</div>
<hr>
Messages:
<ul>
{{#each messages as |message|}}
<li>{{message}}</li>
{{/each}}
</ul>
{{outlet}}
<br>
<br>
{
"version": "0.4.16",
"EmberENV": {
"FEATURES": {}
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.1.0",
"ember-data": "2.1.0",
"ember-template-compiler": "2.1.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment