Skip to content

Instantly share code, notes, and snippets.

@JohnDMathis
Created March 28, 2013 00:17
Show Gist options
  • Save JohnDMathis/5259401 to your computer and use it in GitHub Desktop.
Save JohnDMathis/5259401 to your computer and use it in GitHub Desktop.
It would be very helpful to be able to use request/response with context ("this") properly filled and available in the response function. Is this possible? In the example below, "this" is a reference to the instance 'someView'.
App.views.SomeView=Marionette.ItemView.extend({
initialize:function(){
this.fud = "-quux";
App.reqres.setHandler("foo", function(bar){
return bar + this.fud;
}, this);
}
});
var someView = new App.views.SomeView();
// and then:
var resp = App.request("foo", "bud");
// resp should be "bud-quux"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment