Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mohamedali-s-4725/8ffccad660472740c7484fd36cf53ed6 to your computer and use it in GitHub Desktop.
Save mohamedali-s-4725/8ffccad660472740c7484fd36cf53ed6 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
import UpdateMixin from '../mixins/update';
export default Ember.Component.extend({
child_val: '',
actions:{
childAction(){
alert( 'childAction called..' );
// some validation and ajax call.
self.set( 'updated_val', self.get( 'child_val' ) );
}
}
});
import Ember from 'ember';
/*********** need to import dynamic mixin here ********/
export default Ember.Component.extend({
// updateValue action called from it's hbs file
});
import Ember from 'ember';
import UpdateMixin from '../mixins/update';
export default Ember.Controller.extend(UpdateMixin,{
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Mixin.create({
updated_val: 'Empty',
actions:{
updateValue(){
var self = this;
alert(self.get('updated_val'));
}
}
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.dialog{
border: solid 1px;
width: 300px;
height: 100px;
}
<h1>Trigger action between Parent-to-Child Component</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{{dialog-component}}
<br>
Value Update from child-component: {{ updated_val }}
<div class='dialog'>
{{ child-component child_val=updated_val}}
<button {{action 'updateValue' }}> Update </button>
</div>
{
"version": "0.7.2",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.4/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.4.3/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.4/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment