GJK
GJK

Reputation: 37389

Ember.js Handlebars scoping issue

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.)

Upvotes: 1

Views: 164

Answers (1)

intuitivepixel
intuitivepixel

Reputation: 23322

Maybe this is the right syntax?

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

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

Upvotes: 1

Related Questions