Skip to content

Instantly share code, notes, and snippets.

@theenadayalank
Last active June 26, 2018 05:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theenadayalank/f569bc729486660a9026a945b14f350b to your computer and use it in GitHub Desktop.
Save theenadayalank/f569bc729486660a9026a945b14f350b to your computer and use it in GitHub Desktop.
Parent Child Action
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init() {
this._super(...arguments);
this.rows = [{
id: 1,
fruit: 'Apple',
animal: 'Lion'
}, {
id: 1,
fruit: 'Apple',
animal: 'Lion'
}, {
id: 1,
fruit: 'Apple',
animal: 'Lion'
}
];
},
actions: {
parentAction() {
console.log('parent action');
},
childAction() {
console.log('child action');
}
}
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
<h1>Welcome to {{appName}}</h1>
<div style="background: green; height: 400px; width: 600px;" {{action 'parentAction'}}>
<div style="background: red; height: 200px; width: 400;" {{action 'childAction'}}>
</div>
</div>
<table>'
<thead>
<tr>
<th>#</th>
<th>Apple</th>
<th>Animal</th>
</tr>
</thead>
<tbody>
{{#each rows as | row |}}
<tr {{action 'parentAction' preventDefault=false}}>
<td>
<input type="checkbox" onchange={{action "childAction" value="target.checked"}}>
</td>
<td>{{row.fruit}}</td>
<td>{{row.animal}}</td>
</tr>
{{/each}}
</tbody>
</table>
{
"version": "0.14.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "2.18.2",
"ember-template-compiler": "2.18.2",
"ember-testing": "2.18.2"
},
"addons": {
"ember-data": "2.18.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment