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.)
{{bindAttr}}
instead of normal handlebars{{...}}
. – CraigTeegardenunbound
keyword takes care of that nicely (since I don't really need a binding there). My issue is with scope. And as you can see in my comment to Gevious' answer, it still doesn't make the correct substitution foruuid
. – GJKuuid
in the inner scope, like{{#each service in services}}{{log uuid}}{{/each}}
do you see the loggeduuid
in the console? – intuitivepixel{{#with uuid as outerUUID}} ... {{/with}}
, I can solve my problem. However, this doesn't explain why the scoping doesn't work as it should. – GJKundefined
, as I expected. – GJK