【发布时间】:2013-02-12 17:49:11
【问题描述】:
在下面的Layout 中,我添加了一个CollectionView 以在onRender 中显示一个SELECT 列表。紧接着,我使用 ui 哈希来启用或禁用视图中的所有控件。这不适用于new App.View.Categories 生成的 SELECT。
应该吗?或者 UI 哈希在 Layout 内的 Regions 上不起作用?
App.View.UploadFile = Backbone.Marionette.Layout.extend({
template: '#upload-file-template',
regions:{
category: 'td:nth-child(4)'
},
ui:{
inputs: 'textarea, select, .save'
},
onRender: function(){
this.category.show(
new App.View.Categories({
collection: App.collection.categories
}) // generates the SELECT list
);
console.log(this.ui.inputs); // Length 2. Missing select.
console.log(this.$('textarea, select, .save')); // Length 3
this.ui.inputs.prop(
'disabled', (this.model.get('upload_status')!='staged')
);
}
});
【问题讨论】: