名前がTestClass
のクラスがあります。それはTooltipDialog
オブジェクトメンバーとtestFunc
関数を持っています。
ToolTipDialog
には、ラジオボタンがあります。
ユーザーがラジオボタンをクリックすると、testFunc
が実行されることが予想されます。
質問:私がラジオボタンをクリックしたときに、親コンテキスト(TestClass
)を取得するにはどうすればよいですか? TestClass.testFunc()
のようなものを実行する必要があります。 iはtestFunc
と試みたとき
は、エラーがあった:testFunc is not defined
iはthis.testFunc
と試みた場合、エラーがTestClass
のコードは以下の通りであるthis.testFunc is not a function
JavaScriptのオブジェクトの正しいコンテキストを取得する方法
た、フィドルリンクはjs code
define(["dojo/_base/declare","dojo/dom","dojo/on","dojo/_base/lang","dijit/registry",
"dijit/TooltipDialog","dijit/popup","esri/InfoWindowBase",
"dojo/_base/array"],
function (declare,dom,on,lang,registry,TooltipDialog,popup,InfoWindowBase,Array) {
return declare(
InfoWindowBase,
{
constructor: function (parameters) {
//lang.mixin(this, parameters);
this.son = "";
},
//member of the ParentClass
init: function () {
var tpContent = '<div id="dp1"><label for="name">first:</label> <input type="radio" id="first" checked value="pri"/>' +
'<br><label for="hobby"> second:</label> <input type="radio" id="second" value="sec"/></div>';
this.inherited(arguments);
this.son = new TooltipDialog({
content: tpContent,
onMouseLeave: function (e) {
}
,
onOpen: function (e) {
var sHu=dom.byId("first");
on(sHu,"click", function(){
// this.testFunc();
});
},
});
popup.open({
popup: this.son,
orient: ["above","below"],
around: dom.byId("tpHolder")
});
},
testFunc:function(){
console.log("testFunc");
}
}
);
});
質問は何ですか? [Ask]を確認してください – charlietfl