2
私は次のウィンドウを定義した:私は、ウィンドウを表示する場合メンバーマップをツールバーの保存に使用できないのはなぜですか?
qx.Class.define('my.Window', {
...
construct: function(caption, icon) {
this.base(arguments, caption, icon);
this.setLayout(new qx.ui.layout.VBox(10));
this.add(new qx.ui.form.renderer.Single(this.getForm('some')));
this.add(new qx.ui.form.renderer.Single(this.getForm('other')));
this.add(this.getToolbar('test')); // This is shown
this.add(this.getToolbar('some')); // This is not shown
this.add(this.getToolbar('other')); // This is not shown
},
members: {
_forms: {},
_toolbars: {},
getForm: function(id) {
if(this._forms[id]) return this._forms[id];
if(id = 'some') this._forms[id] = new Form();
else if(id == 'other') this._forms[id] = new OtherForm();
return this._forms[id];
},
getToolbar: function(id) {
if(id == 'test') {
if(this._tb) return this._tb;
this._tb = new TestToolbar();
return this._tb;
}
else if(id == 'some') this._toolbars[id] = new SomeToolbar();
else if(id == 'other') this._toolbars[id] = new OtherToolbar();
return this._toolbars[id];
}
}
});
、フォーム(「一部」と「他の」)が示されています。 TestToolbarやListなどの他の項目も表示されます。しかし、他のツールバー( 'test'、 'some'、 'other')は表示されません。
_toolbars
をオブジェクトから配列に変更しようとしましたが、同じ動作があります。
ノートで仕事をしてあなたの例を少し変更したバージョンだ...あなたは、コンストラクタでこのTODO持っているか、彼らはによって共有されますあなたのクラスのすべてのインスタンス... this._forms = {}; –
これをプレイグラウンドhttps://demo.qooxdoo.org/current/playgroundに追加すると、他の人があなたのコードがどのように失敗するのかが分かりやすくなります。 –
YeshuaはTobiに完全なplaygoundサンプルを作成してください。障害のある動作を複製することができれば、コードの何が間違っているかを簡単に知ることができます。しかし、あなたの質問への短い答えを与えるために、メンバーマップ、たとえツールバーのインスタンスでもインスタンスを保持することは可能です。 – level420