Skip to content

Instantly share code, notes, and snippets.

@mohamedali-s-4725
Last active April 21, 2016 07:49
Show Gist options
  • Save mohamedali-s-4725/3b32763c2445ed1fb0efbe9b785ac670 to your computer and use it in GitHub Desktop.
Save mohamedali-s-4725/3b32763c2445ed1fb0efbe9b785ac670 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
name: 'Hi',
actions:{
childAction(){
alert( 'childAction called..' );
var self = this;
self.set( 'name', 'childAction' );
}
}
});
import Ember from 'ember';
import UpdateMixin from '../mixins/update';
export default Ember.Component.extend(UpdateMixin, {
parent_val: 'SMA',
actions:{
getValue(){
var self = this;
//alert( self.get('parent_val') );
self.send( 'updateVal', self.get('parent_val') );
}
}
});
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:{
updateVal( value ){alert(value);
var self = this;
// value = value === undefined ? 'No Value' : value;
self.set( 'updated_val', value );
}
}
});
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}}
Updated Value from Component: {{ updated_val }}
<div class='dialog'>
{{ child-component val=parent_val}}
<button {{action 'getValue' }}> 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