Skip to content

Instantly share code, notes, and snippets.

@nfc036
Last active February 11, 2024 04:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nfc036/00c110c26ca37a29019124f7ad46001d to your computer and use it in GitHub Desktop.
Save nfc036/00c110c26ca37a29019124f7ad46001d to your computer and use it in GitHub Desktop.
Action bubbling from components
import Ember from 'ember';
export default Ember.Component.extend({
layout: Ember.computed.alias('contentTemplate'),
});
import Ember from 'ember';
import hbs from 'htmlbars-inline-precompile';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
result: '',
myContentTemplate: hbs('<button class="btn" {{action "testAction"}}>Click me</button>'),
actions: {
testAction() {
this.set('result', 'TestAction called.');
}
}
});
<h1>Welcome to {{appName}}</h1>
<p>
{{my-component contentTemplate=myContentTemplate}}
<h1>{{result}}</h1>
</p>
<p>Using ember 2.8.0 this works, using "release" (currently 2.8.2) the component logs an error.</p>
<div class="alert alert-danger"><pre>VM188 ember.debug.js:6778 Uncaught Error: Assertion Failed: &lt;twiddle@component:my-component::ember355&gt; had no action handler for: testAction</pre></div>
<br>
<br>
{{outlet}}
<br>
<br>
{
"version": "0.10.5",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "release",
"ember-data": "2.8.0",
"ember-template-compiler": "release",
"ember-testing": "release",
"ember-cli-htmlbars-inline-precompile": "^0.3.5"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment