Skip to content

Instantly share code, notes, and snippets.

@phiggins42
Created March 7, 2011 18:15
Show Gist options
  • Save phiggins42/858908 to your computer and use it in GitHub Desktop.
Save phiggins42/858908 to your computer and use it in GitHub Desktop.
dojo.declare("Foo", null, {
url:"/example.txt",
constructor: function(){
dojo.xhrGet({
url: this.url,
// pass a string as 2nd to hitch(). means this._handler():
load: dojo.hitch(this, "_handler"),
// or a function. 1st arg means context to use
error: dojo.hitch(this, function(response){
/* `this` is the context of the instance, hitched before */
})
})
},
_handler: function(data){
/* called by the xhr call in constructor */
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment