问题
Is there a way to set a binding in handlebars for a view and then use that in the template?
{{view App.SKillView skillBinding="Skill1"}}
and then in the template use that binding such as:
<script type="text/x-handlebars" data-template-name="skill">
<h5>{{skill}}</h5>
<div {{action spendPoints skill 1}}></div>
</script>
The view class is really simple:
App.SkillView = Ember.View.extend({
templateName:'skill',
classNames: ['skill']
});
These seems really simple, but for the life of me I can't figure it out. Any help would be appreciated. I basically want to be able to dynamically reuse the same view through my App and have it affect different skills in each place. Thanks!
回答1:
You're pretty much there, you just need to access the properties via the view
<script type="text/x-handlebars" data-template-name="skill">
<h5>{{view.skill}}</h5>
<div {{action spendPoints view.skill 1}} href="#"></div>
</script>
回答2:
Have you tried adding attributeBindings: ['skill'] to your view?
来源:https://stackoverflow.com/questions/16574349/set-and-access-view-bindings-in-handlebars