Skip to content

Instantly share code, notes, and snippets.

@czosel
Created March 28, 2017 07:04
Show Gist options
  • Save czosel/c1ba54cfde81c977cfee173370a19e0f to your computer and use it in GitHub Desktop.
Save czosel/c1ba54cfde81c977cfee173370a19e0f to your computer and use it in GitHub Desktop.
contextual components with inbound actions
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
reset() {
this.get('myInput').send('reset');
}
}
});
import Ember from 'ember';
import InboundActions from 'ember-component-inbound-actions/inbound-actions';
export default Ember.Component.extend(InboundActions, {
actions: {
reset() {
console.log('reset child', this.get('name'));
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{#my-form as |f|}}
{{f.input name="first"}}
{{f.input name="second"}}
{{/my-form}}
<br>
<br>
<h3>my form</h3>
{{yield (hash
input = (component 'my-input' actionReceiver=myInput)
)}}
<button {{action "reset"}}>Reset</button>
<h4>my-input ({{name}})</h4>
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-component-inbound-actions": "1.2.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment