カスタム ウィジェットがありlang.hitch
、特定の方法で使用できるかどうか知りたいです。シナリオは次のとおりです。
を含むカスタム ウィジェットがあるとしますButton
。そのイベントButton
にアタッチされた関数が必要です。onClick
したがって、私のテンプレートには次のものがあります。
<button data-dojo-type="dijit/form/Button" data-dojo-attach-event="onClick : _onButtonClick" />
次に、私のウィジェット.js
ファイルには次のものがあります。
_onButtonClick : function(evt) {
//do something here that needs the scope of my widget (this)
}
data-dojo-attach-event
テンプレートからを削除しdojo.connect
てlang.hitch
inで使用できることはわかっていますが、単に関数を次postCreate
のように変換できるかどうか疑問に思っています。_onButtonClick
_onButtonClick : lang.hitch(this, function(evt) {
//do something here that needs the scope of my widget (this)
})