Skip to content

Instantly share code, notes, and snippets.

@Panman82
Last active May 12, 2016 21:07
Show Gist options
  • Save Panman82/cdd3e801caaeb58c8d8ccf280eeeafe6 to your computer and use it in GitHub Desktop.
Save Panman82/cdd3e801caaeb58c8d8ccf280eeeafe6 to your computer and use it in GitHub Desktop.
Cards List w/ Dynamic Buttons
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
noop( card ) {},
removeCard( card ) {
let cards = this.get('model');
cards.removeObject( card );
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return [{
title: "Card 1",
content: "This is the first card."
}, {
title: "Card 2",
content: "Foo bar baz quux"
}, {
title: "Card 3",
content: "Lorem ipsum dolar"
}];
}
});
<h3>Cards List w/ Dynamic Buttons</h3>
<h5>Number of cards: {{model.length}}</h5>
<br>
<h4>With Dismiss</h4>
{{card-list items=model
actionButtons=(array
(hash text="Dismiss" action=(action "removeCard"))
(hash text="Foobar" action=(action "noop"))
)
}}
<h4>Without Dismiss</h4>
{{card-list items=model}}
{{#each items as |item|}}
{{#mdl-card title=item.title}}
<div class="mdl-card__supporting-text">
{{item.content}}
</div>
{{#if actionButtons}}
{{#mdl-card-actions}}
{{#each actionButtons as |button|}}
{{mdl-button text=button.text on-click=(action button.action item)}}
{{/each}}
{{/mdl-card-actions}}
{{/if}}
{{/mdl-card}}
<br>
{{/each}}
{
"version": "0.8.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"addons": {
"ember-material-lite": "latest",
"ember-array-helper": "latest"
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.5.1",
"ember-data": "2.5.2",
"ember-template-compiler": "2.5.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment