Skip to content

Instantly share code, notes, and snippets.

@sheriffderek
Forked from phkavitha/application.controller.js
Last active October 2, 2015 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sheriffderek/f44a48607738a0b9af81 to your computer and use it in GitHub Desktop.
Save sheriffderek/f44a48607738a0b9af81 to your computer and use it in GitHub Desktop.
StackOverFlow-32855039
import Ember from 'ember';
// model is in the route
export default Ember.Controller.extend( {
actions: {
showCover(book) {
book.set('coverVisible', true);
console.log(book.coverVisible);
}
}
});
// route = 'this' > model > books > book > coverVisible
import Ember from 'ember';
var bookData = [
{
name: "Book1",
thing: 'all at the same time :(',
coverVisible: false
},
{
name: "Book2",
thing: 'all at the same time :(',
coverVisible: false
},
{
name: "Book3",
thing: 'all at the same time :(',
coverVisible: false
}
];
export default Ember.Route.extend({
model() {
return bookData;
}
});
<h1>Welcome to {{appName}}</h1>
<ul>
{{#each model as |book|}}
<li> {{book.name}} -
{{#if book.coverVisible}}
{{book.thing}}
{{/if}}
{{#unless book.coverVisible}}
<button {{action "showCover" book}}>
Show Cover
</button>
{{/unless}}
</li>
{{/each}}
</ul>
import DS from 'ember-data';
var type = function(input) {
return DS.attr(input);
};
export default DS.Model.extend({
name: type('string'),
thing: type('string'),
readingReview: type('boolean')
});
{
"version": "0.4.11",
"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.9/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.11/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.9/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment