1

I'm having a scoping issue with Handlebars templates. I have a list of modules, each of which contains a list of services. So I have a template like this (with some markup removed):

{{#each controller}}
    <a onclick='$(".{{unbound uuid}}").toggle(0);'>

    {{#each service in services}}
        <div class='{{unbound uuid}}'></div>
    {{/each}}
{{/each}}

The problem is that the second {{unbound uuid}} doesn't get substituted. And if I try accessing any other item of the outer scope, the same thing happens. However, the Ember.js site says that using the each ... in helper should preserve outer scope. What am I doing wrong?

(FYI: Using latest version of Ember.js, Ember-data and Handlebars.)

4

1 回答 1

1

也许这是正确的语法?

{{#each item in controller}}
  <a onclick='$(".{{unbound item.uuid}}").toggle(0);'>

  {{#each service in services}}
    <div class='{{unbound item.uuid}}'></div>
  {{/each}}
{{/each}}
于 2013-07-16T13:17:31.813 回答