Reputation: 41
to create ember object and view dynamically such as
App[a] = Ember.Object.create({realName: b.name})
App[a] = Ember.View.create(
tagName: b.tag
template: Ember.Handlebars.compile '{{???}}'
)
i can not put App[a+'Widget'].realName in the handlebar template, is that possible to do it in some other ways? see http://jsfiddle.net/lily/qSWAh/2/
Upvotes: 0
Views: 243
Reputation: 3281
The handlebars template will be evaluated in the context of the view at the time it is rendered. Therefore, if you want to refer to {{realName}}
directly, you'll need to define realName
on your view. If you want to evaluate realName
in some other scope, say for App
, just specify it like this: {{App.realName}}
.
I don't fully grok the intent of your example, but you may want to do something like this to store your "widget" object on your view:
App[a + "Widget"] = Ember.Object.create({realName: b.name})
App[a + "View"] = Ember.View.create(
appWidget: App[a + "Widget"]
tagName: b.tag
template: Ember.Handlebars.compile '{{appWidget.realName}}'
)
Upvotes: 1