0
我正在研究Ember.js类来帮助处理表单。在下面的片段中,我的widget
的定义需要绑定到它的value
,以便嵌套它的对象的属性,因此我将绑定设置为'App.AjaxForm.aField.value'
。如何在嵌套对象定义中引用Ember.js对象?
有没有一个不太重复的方式来说这个?
App.Field = Ember.Object.extend({
// The Ember.js equivalent of ``django.forms.fields.Field``.
value: null,
errors: [],
widget: null
});
App.AjaxForm = App.Form.create({
action: '/ajax/',
fields: [
'aField'
],
aField: App.Field.create({
widget: Ember.TextField.extend({
valueBinding: 'App.AjaxForm.aField.value'
})
})
});
更新:增加了App.Field
的定义。
这个问题有点混乱(至少对我来说)。你想要的东西像valueBinding:'parentView.value'。不知道你是如何实现App.Field将很难给出完整的答案。 –
@CoryLoken我想'parentView.value'是类似于我想要的。我用'App.Field'的定义更新了这个问题。它只是一个具有几个属性的Ember对象。 – hekevintran