1

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.

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Arg ... yea Revision 10, someone needs to delete: cloud.github.com/downloads/emberjs/data/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.