Note that there are some explanatory texts on larger screens.

plurals
  1. POtemplate syntax for related data
    primarykey
    data
    text
    <p>This seems like it should be simple. Suppose I have the following model:</p> <pre><code>App.Folder = DS.Model.extend({ folder_id: DS.attr('number'), folder_name: DS.attr('string'), items: DS.hasMany('App.Item') }); App.Item = DS.Model.extend({ item_id: DS.attr('number'), folder_id: DS.attr('number'), item_name: DS.attr('string'), folder: DS.belongsTo('App.Folder') }); </code></pre> <p>...and the following data:</p> <pre><code>App.Folder.FIXTURES = [ { id: 1, folder_name: 'My First Folder', items: [100] }, { id: 2, folder_name: 'Another Folder', items: [101] }, { id: 3, folder_name: 'Folder 3', items: [102] } ]; App.Item.FIXTURES = [ { id: 100, folder_id: 1, item_name: 'This is an item' }, { id: 101, folder_id: 2, item_name: 'A cleverly named item' }, { id: 102, folder_id: 3, item_name: 'This one is also an item in a folder' } ]; </code></pre> <p>Now, in my "item" template, shouldn't I be able to do something like this to show the folder related to an item:</p> <pre><code>&lt;script type="text/x-handlebars" data-template-name="snapshot"&gt; &lt;div class="row-fluid property-row-alt"&gt; &lt;div class="span4 property-label"&gt;item name:&lt;/div&gt; &lt;div class="span8"&gt;{{ item_name }}&lt;/div&gt; &lt;/div&gt; &lt;div class="row-fluid property-row"&gt; &lt;div class="span4 property-label"&gt;folder:&lt;/div&gt; &lt;div class="span8"&gt;{{ folder.folder_name }}&lt;/div&gt; &lt;/div&gt; &lt;/script&gt; </code></pre> <p>"<strong>folder.folder_name</strong>" is the key syntax I'm trying to nail down here. Maybe this isn't possible, but I'm hoping to get the related folder and drill down into it's folder_name inside my item template. Can I do this in Ember? Using the latest versions.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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