2 つのスクリプト コントロールがあり、1 つのコントロールにもう 1 つの子コントロールがあるとします。
ParentControl : ScriptControl
{
ChildControl childControl;
}
子コントロールのスクリプト:
ChildControl = function(element)
{
ChildControl.initializeBase(this, [element]);
}
ChildControl.prototype =
{
callMethod: function()
{
return 'hi';
},
initialize: function()
{
ChildControl.callBaseMethod(this, 'initialize');
},
dispose: function()
{
ChildControl.callBaseMethod(this, 'dispose');
}
}
スクリプト側では、子コントロールのメソッドを呼び出したい:
ParentControl.prototype =
{
initialize: function()
{
this._childControl = $get(this._childControlID);
this._childControl.CallMethod();
ParentControl.callBaseMethod(this, 'initialize');
},
dispose: function()
{
ParentControl.callBaseMethod(this, 'dispose');
}
}
問題は、これを試すたびに、このメソッドが見つからないかサポートされていないと表示されることです。ChildControl のすべてのメソッドに ParentControl からアクセスできるようにすべきではありませんか?
ParentControl がそれを見ることができるように、メソッドを公開する必要がある方法はありますか?
更新 this._childControl を「入力」することは可能でしょうか?
これが私が尋ねる理由です... Watchを使用すると、システムはChildControlクラスが何であるかを認識し、クラス自体からメソッドを呼び出すことができますが、this._childControlオブジェクトから同じメソッドを呼び出すことはできません. メモリ内のクラス設計 (?) が既存のメソッドを認識し、そのクラスからインスタンス化されたオブジェクトも認識すると考えるでしょう。