Binding child views and collections within an outlet in emberjs

旧时模样 提交于 2019-12-06 09:38:38
horlick

You can use

{{view App.PersonView contextBinding="leader"}}

and use {{#each}} instead of {{#collection}} for the members

http://jsfiddle.net/LQTsV/1/

Not very sure whats going on but I tweaked your fiddle to get it working:

http://jsfiddle.net/lifeinafolder/sPcwv/

Seems as if bindings are not working properly in the sense:

contentBinding="this"

works but

contentBinding="this.leader"

doesn't.

Sorry but I couldn't work it out more.

You're setting the content variable on person view via contentBinding that should probably be personBinding. And then in your template you should get the view.person.name.

{{collection}} should be a {{each}} block.

{{#each members}}
    {{view App.PersonView personBinding="this"}}
{{/each}}

And this person template will look in the right location for the name.

<script type="text/x-handlebars" data-template-name="person">
    <em>Person name is:</em> {{view.person.name}}
</script>

Didn't change your js.

fiddle: http://jsfiddle.net/albertjan/fkKFJ/9/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!