javascript - dojo - lang.hitch for widget function -


i have custom widget , curious if can use lang.hitch in particular way. here scenario:

say have custom widget contains button. button needs function attached onclick event. so, in template have:

<button data-dojo-type="dijit/form/button" data-dojo-attach-event="onclick : _onbuttonclick" /> 

then, in widget .js file have:

_onbuttonclick : function(evt) {     //do here needs scope of widget (this) } 

i know remove data-dojo-attach-event template , use dojo.connect lang.hitch in postcreate, i'm wondering if convert _onbuttonclick function this:

_onbuttonclick : lang.hitch(this, function(evt) {     //do here needs scope of widget (this) }) 

data-dojo-attach-event automatically makes scope of this parent widget.

i'm not 100% sure, don't think context of this in snippet declare([/deps/,{

    _onbuttonclick : lang.hitch(this, function(evt) {       //do here needs scope of widget (this)     })  }); 

is want to. believe when function bound scope declare function executed in, rather instance of widget.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -