Skip to content

Instantly share code, notes, and snippets.

@sajt
Last active August 29, 2015 14:28
Show Gist options
  • Save sajt/c69f7c03ed54db949f9b to your computer and use it in GitHub Desktop.
Save sajt/c69f7c03ed54db949f9b to your computer and use it in GitHub Desktop.
Sajt_1
import Ember from 'ember';
export default Ember.Controller.extend({
model: [
{id: 1,
name: 'First',
extra: 'First extra'
},
{
id: 2,
name: 'Second',
extra: 'Second extra'
}
],
actions: {
showMatch(match) {
this.set('model', this.get('model').map(function(currmatch) {
currmatch.showExtra = (currmatch.id === match.id);
console.log(currmatch.id, match.id)
return currmatch;
}));
}
}
});
<table class="table table-striped" border="1">
<thead>
<th>Name</th>
</thead>
<tbody>
{{#each model as |match|}}
<tr>
<td><a href="#" {{action "showMatch" match}}>{{match.name}}</a></td>
</tr>
{{#if match.showExtra}}
<tr>
<td colspan="1">
<table class="table table-striped">
<tr><th>Away</th><td>{{match.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