user1017736
user1017736

Reputation: 3

Ember.js / Handlebars: views rendered using {{view}} helper not binding attributes

I have a mysterious issue with Ember/Handlebars views. I am attempting to implement very simple data binding in a Handlebars view. This works correctly when render my view by doing:

Ember.Views.NavView.create().append()

But the bound attribute isn't shown when I attempt to render another instance of the same view using the {{view}} helper, like so:

<script type="text/x-handlebars">
    {{view App.Views.NavView}}
</script>

In the first case the attributes (hardcoded on the View for this test-case) are shown correctly. In the second case I get "metamorph-0-start" and "metamorph-0-end" tags, but the value itself is not rendered.

I have set up a JSFiddle (http://jsfiddle.net/XUyht/2/) that illustrates the problem clearly.

You'll see that I have rendered the view twice: the first using the {{view}} helper and the second using append() - but the attribute "working" only shows in the latter case.

What's going on here?

Upvotes: 0

Views: 1438

Answers (1)

sly7_7
sly7_7

Reputation: 12011

I don't know why you need this kind of implementation of the template, but anyway, since the 1.0-pre, the default context of a view is either its controller, either its parent view. So in your case, if you replace tmp.foo with view.tmp.foo, this is working.

see http://jsfiddle.net/Sly7/amLfk/

Upvotes: 2

Related Questions