假设我有两个脚本控件,一个控件将另一个控件作为子控件:
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');
}
}
问题是,每次我尝试这都是说找不到或不支持这种方法。ParentControl 不应该可以访问 ChildControl 上的所有方法吗?
有什么方法我必须公开该方法以便 ParentControl 可以看到它?
更新 是否可以“键入” this._childControl?
这就是我问的原因...当我使用 Watch 时,系统知道 ChildControl 类是什么,我可以从类本身调用方法,但是,我不能从 this._childControl 对象调用相同的方法。您会认为,如果内存中的类设计(?)识别出存在的方法,并且从该类实例化的对象也会。