0

カスタム ウィジェットがあり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.connectlang.hitchinで使用できることはわかっていますが、単に関数を次postCreateのように変換できるかどうか疑問に思っています。_onButtonClick

_onButtonClick : lang.hitch(this, function(evt) {
    //do something here that needs the scope of my widget (this)
})
4

1 に答える 1