Reputation: 21536
I'm helping somebody out and building a pretty simple app while learning Ember.js.
Eventually, this will be fed by an API, but the API is still in development, so I'm trying to figure out how to use Fixtures with Ember Data to manage a list of wines.
The jsfiddle is http://jsfiddle.net/YvmzN/5/
What I'm trying to do is that when a varietal is selected from the list, return a list of wines that match that varietal. However, I'm not getting any output. I get some very strange errors from web inspector in jsfiddle, but I don't get any errors locally, just no wines show up on the page.
I can't seem to figure out the flow, and I am unable to output
console.log(this)from within my controller
App.WineRoute.model
, so I can't even tell if the controller is being triggered (I'm guessing it's not).
Can somebody guide me in what I'm doing wrong here, and maybe explain the structure of what's happenging in Ember and how you debug?
I thought it was supposed to go Router -> Route -> Controller -> Model -> Controller -> View, but I can't seem to track down the flow properly or see why this isn't working.
As mentioned in the JSfiddle, I'm currently pulling the list of wines from a local JSON file, in the long-run, I'll request the already filtered list from an API, but I'd still like to know how to do this at this point.
Upvotes: 0
Views: 1081
Reputation: 47367
Here's a portion of the answer until you have more information:
In order to really use Ember Data properly each record needs to have an id.
App.Wine.FIXTURES =[
{
id:0,
winery:"something hills",
designation:"label name",
varietal:"Merlot"
},
{
id:1,
winery:"something stream",
designation:"label name 2",
varietal:"Merlot"
},
{
id:2,
winery:"something grape",
designation:"label name 3",
varietal:"Syrah"
}
];
Ember Data introduced a slew of changes between revision 13 and 1.0 beta. Here is an excellent read (from the developers explaining what should be done differently).
https://github.com/emberjs/data/blob/master/TRANSITION.md
The adapters are really pertinent, here's how you should define your adapter now
App.ApplicationAdapter= DS.FixtureAdapter;
I've done some major refactoring, and to be honest, I'm not very familiar with wine, so I might have some of the terminology wrong, or the relationships, but here's an example and a lot you can work off of.
And just as a fun side note, you don't hit the model hooks if you call transitionTo/transitionToRoute and provide the model necessary for the route. If you don't provide the model (or provide an id) it will hit the model hook in the applicable route (pretty sure there was an example of this, I say transition to wines, but only pass in the model for the variety, so it has the model for the variety resource, but not for the wines resource, so it hits the wines model hook).
Upvotes: 2