-1
我有一组面板(现在三个),它们是同一个视图的所有实例。 所以他们有很多共同的东西,比如工具栏和它们上的按钮。当变量发生变化时更新一组面板
我定义工具栏和按钮的文字时,我在它们与文字来自于一个变量,像这样:
App.views.CommonView = Ext.extend(Ext.Panel, {
initComponent: function() {
this.backBtn = new Ext.Button({
text: globalVar,
handler: this.onBackTap,
scope: this
});
this.toolbar = new Ext.Toolbar({
title: this.title,
items: [this.backBtn]
});
}
});
anInstanceView: new App.views.CommonView({
title: globalVar
});
anotherInstanceView: new App.views.CommonView({
title: globalVar
});
正如你所看到的,按钮上的文字和工具栏标题依赖于globalVar 。
我想,当我改变这个golbalVar的价值
globalVar = "new value";
// Somehow update all the button and toolbar texts on all three panels.
我不想这样做手工想更新这些文本一起;
App.views.anInstanceView.getDockedItems[0].setTitle(globalVar);
并对所有面板重复该操作。需要有一个更清洁的解决方案,一种更新用户界面的方法。
什么是更清洁的解决方案? 谢谢。
这是一个很好的解决我的问题。非常感谢,谢谢。 – keune