I have a jsfiddle example, that I cannot apply a FixtureAdapater to. I am terrible at ember and am trying to learn but I cannot get this to work. Any help would be much appreciated, thank you so very much
HTML
<body>
<script type="text/x-handlebars" data-template-name="MessageManager">
<ul>
{{#each item in model}}
<li>{{item}}</li>
{{/each}}
</ul>
</script>
</script>
</body>
JAVASCRIPT
window.MessageManager = Ember.Application.create();
MessageManager.Store = DS.Store.extend({
revision: 13,
adapter: DS.FixtureAdapter.create()
});
MessageManager.Router.map(function() {
this.resource('MessageManager',{path :'/'});
});
MessageManager.MessageManagerRoute = Ember.Route.extend({
model: function() {
var x = this.store.find('Message');
}
});
MessageManager.Message = DS.Model.extend({
id:DS.attr('id'),
SendingPhoneNumber : DS.attr('string'),
ReceivingPhoneNumber : DS.attr('string'),
DateReceived : DS.attr('date')});
MessageManager.Message.FIXTURES = [
{
id:1,
SendingPhoneNumber :'555 555 9219',
ReceivingPhoneNumber :'555 555 1646',
Message : 'Why Do i have a 5 dollar charge on my phone bill',
DateReceived :'2014-02-21'
},
{
id:2,
SendingPhoneNumber :'555 555 9219',
ReceivingPhoneNumber :'555 555 1678',
DateReceived :'2014-02-18'
}];
There were a couple of errors a fixed version in on jsbin . I'm not sure which version of ember-data you're using, but ember-data changed the way you set the adapter, you set a factory instead of an instance:
adapter: DS.FixtureAdapter
Instead of:
adapter: DS.FixtureAdapter.create()
Also, there's no need to set the id attribute on your model definition and you have an extra closing tag for the script element.
Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.