Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to load child object with parent in ember
    primarykey
    data
    text
    <p>I am using Ember RC2 and Ember-Data 12 have the following relationship (simplified): </p> <pre><code>App.GlobalData = DS.Model.extend({ lat: DS.attr('number'), lon: DS.attr('number'), }); App.System = DS.Model.extend({ title: DS.attr('string'), data: DS.belongsTo('App.GlobalData'), }); </code></pre> <p>In my (System) view I now want to access the child's data like this: <code>{{ data.lat }}</code> </p> <p>It seems like Ember (currently I am using the FixtureAdapter, but I would also like to make this work with the RESTadapter in the future) does not automatically load the child element data. While <code>{{ data.id }}</code> returned the value of the id (as specified in the App.GlobalData.FIXTURES), <code>{{ data.lat }}</code> returned <code>undefined</code>.</p> <p>I somewhat got around this issue by creating an array controller:</p> <pre><code>App.GlobalDatasController = Ember.ArrayController.extend({}); App.globalDatasController = App.GlobalDatasController.create({}); </code></pre> <p>and preloading all GlobalData in my ApplicationRoute</p> <pre><code>App.ApplicationRoute = Ember.Route.extend({ setupController: function() { App.globalDatasController.set('content', App.GlobalData.find()); } }); </code></pre> <p>However, this does not seem like a good solution, because it requires me to load <em>all</em> GlobalData, even though I may only need one.</p> <p>I am sure there is a best practice on how to handle this, however, despite my best research efforts I have not been able to find it. </p> <p>To summarize my question: </p> <ol> <li>How and where do I tell ember to load child data with the parent (without sideloading it)?</li> <li>If sideloading is the only option, how would I implement that in the FixtureAdapter?</li> </ol> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload