Note that there are some explanatory texts on larger screens.

plurals
  1. POember controller for rendered template
    primarykey
    data
    text
    <p>I have a collection of foos, and each foo has its own collection of bars. I want to be able to display a selected foo using routes, but then the foo's bars are listed as part of the display.</p> <p>All that is straight forward except that each bar may contain an attribute that means I want to apply different styles to it. So, I am using a <em>render</em> handlebars helper inside an <em>each</em> , like so -</p> <pre><code>&lt;script type="text/x-handlebars" id="foo"&gt; &lt;div&gt;{{name}}&lt;/div&gt; &lt;div&gt; &lt;table&gt; {{#each bar in bars}} {{render bar bar}} {{/each}} &lt;/table&gt; &lt;/div&gt; &lt;/script&gt; </code></pre> <p>and the bar template looks like this -</p> <pre><code>&lt;script type="text/x-handlebars" data-template-name="bar"&gt; &lt;tr&gt;&lt;td&gt; &lt;div {{bind-attr class="bar.bold:bold"}}&gt;{{bar.name}}&lt;/div&gt; &lt;/td&gt;&lt;/tr&gt; &lt;/script&gt; </code></pre> <p>The thing is that I can't figure out how to define the controller. The above just works if the model contains bars with a bold property but what if that's not the case and I need to calculate the property?</p> <p>I tried variations on this -</p> <pre><code>App.BarController = Ember.ObjectController.extend({ isBold: function(){ return this.get('bold'); }.property('isBold'),}); </code></pre> <p>(modifying the bind-attr helper accordingly), and I put a breakpoint on the return. It is never hit.</p> <p>I have a jsfiddle here (<a href="http://jsfiddle.net/martinp999/ZbjH9/7/" rel="nofollow">http://jsfiddle.net/martinp999/ZbjH9/7/</a>). Any advice would be appreciated. Thanks</p>
    singulars
    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