Last active
October 19, 2015 22:58
-
-
Save trabus/3dfcce6400eadcab1e72 to your computer and use it in GitHub Desktop.
demo for brandon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName:'Ember Twiddle', | |
initData: Ember.on('init',function(){ | |
// this would normally happen with the route model hook | |
// when the data response comes back, this happens automatically behind the scenes | |
this.store.pushPayload({yearbooks:[ | |
{id: 1, name: 'yearbook 1'}, | |
{id: 2, name: 'yearbook 2'}, | |
{id: 3, name: 'yearbook 3'} | |
]}); | |
}), | |
count: 3, | |
actions: { | |
pushModel: function(){ | |
var records = {yearbooks: []}; | |
var count = this.get('count') | |
for(var i = count; i < count + 3; i++){ | |
records.yearbooks.push({ | |
id: i, | |
name: 'yearbook ' + i | |
}); | |
console.log(i); | |
} | |
// this happens automatically when data is received | |
this.store.pushPayload(records); | |
this.set('count', count+3) | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model: function(params){ | |
// this method only looks for local records | |
// normally we'd use find, which makes a network request | |
return this.store.peekAll('yearbook'); | |
}, | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from 'ember-data'; | |
export default DS.Model.extend({ | |
name: DS.attr() | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.4.13", | |
"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.10/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.13/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.10/ember-template-compiler.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment