Reputation: 577
Just trying to get a fiddle set up to solve a few other issues, and I cant get passed what should be a simple setup.
In older version of ember, I can get access to Fixture data using find(): http://jsfiddle.net/jdcravens/Btum7/
App = Ember.Application.create();
App.Store = DS.Store.extend({
revision: 11,
adapter: "DS.FixtureAdapter"
});
App.Team = DS.Model.extend({
name: DS.attr('string'),
colors: DS.attr('string')
})
App.Team.FIXTURES = [{
id: 1,
name: 'Celtics',
colors: 'Green, White'
}, {
id: 2,
name: 'Lakers',
colors: 'Yellow, Black'
}, {
id: 3,
name: 'Bulls',
colors: 'Red, Black'
}, {
id: 4,
name: 'Mavericks',
colors: 'Blue, White'
}, {
id: 5,
name: 'Spurs',
colors: 'Black, Grey, White'
}];
App.Router = Ember.Router.extend();
App.Router.map(function (match) {
match("/").to("home");
});
App.HomeRoute = Ember.Route.extend({
setupController: function (controller) {
controller.set('content', App.Team.find());
}
});
And use the template:
<script type="text/x-handlebars" data-template-name="home">
<ul class="teams">
{{#each team in content}}
<li>{{team.name}}</li>
{{/each}}
</ul>
</script>
But in all of the latest libraries, I get App.Team as undefined: http://jsfiddle.net/jdcravens/JTWjU/6/
App = Ember.Application.create({});
App.Store = DS.Store.extend({
revision: 12,
adapter: "DS.FixtureAdapter"
});
App.Team = DS.Model.extend({
name: DS.attr('string'),
colors: DS.attr('string')
});
App.Team.FIXTURES = [{
id: 1,
name: 'Celtics',
colors: 'Green, White'
}, {
id: 2,
name: 'Lakers',
colors: 'Yellow, Black'
}, {
id: 3,
name: 'Bulls',
colors: 'Red, Black'
}, {
id: 4,
name: 'Mavericks',
colors: 'Blue, White'
}, {
id: 5,
name: 'Spurs',
colors: 'Black, Grey, White'
}];
App.Router.map(function () {
this.resource("home", {path: "/"})
});
App.HomeRoute = Ember.Route.extend({
setupController: function (controller) {
console.log(App)
controller.set('content', App.Team.find());
}
});
I'm at a loss.
Upvotes: 1
Views: 1833
Reputation: 3971
Your code is fine. You are using an outdated version of Ember Data.
You can get the latest ember data at: http://builds.emberjs.com.s3.amazonaws.com/ember-data-latest.js
Update the ember-data.js file and it will work.
Upvotes: 3