Skip to content

Instantly share code, notes, and snippets.

@sajt
Forked from eahmedshendy/controllers.application.js
Created August 23, 2015 18:59
Show Gist options
  • Save sajt/1f562151af06dff84bd6 to your computer and use it in GitHub Desktop.
Save sajt/1f562151af06dff84bd6 to your computer and use it in GitHub Desktop.
Test
import Ember from 'ember';
export default Ember.Controller.extend({
show: null,
menus: Ember.computed('model', function() {
return this.model;
}),
actions: {
showMatch(menu) {
//alert('Start');
Ember.set(menu, 'showExtra', true);
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return [
{
id: 1,
name: 'First',
extra: 'First extra',
showExtra: false
},
{
id: 2,
name: 'Second',
extra: 'Second extra',
showExtra: false
}
]
}
});
<table class="table table-striped" border="1">
<thead>
<th>Name</th>
</thead>
<tbody>
{{#each menus as |menu|}}
<tr>
<td><a href="#" {{action "showMatch" menu}}>{{menu.name}}</a></td>
</tr>
{{#if menu.showExtra}}
<tr>
<td colspan="1">
<table class="table table-striped">
<tr><th>Away</th><td>{{menu.extral}}</td></tr>
</table>
</td>
</tr>
{{/if}}
{{/each}}
</tbody>
</table>
{
"version": "0.4.8",
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.8/ember.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.9/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.8/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment