add "context" support to glow.net.*
Reported by Michael Stillwell | August 11th, 2009 @ 02:44 PM | in 2.0
glow.events.addListener() has support for an optional 4th parameter which determines what "this" corresponds to within the callback. It would be useful if the glow.net.* methods supported something similar.
i.e. something to accomplish the following, but built-in:
var self = this;
glow.net.loadScript(
"http://foo.com/?jsoncallback={callback}",
{
onLoad: (function(context){
// fn is the function for which we want to control the scope of "this"
var fn = function(data) {
// at this point, "this" refers to the same thing as "self"
};
return function(data) {
fn.apply(context, arguments)
}
})(this)
}
);
Comments and changes to this ticket
-
Jake Archibald August 26th, 2009 @ 01:34 PM
- Tag set to enhancement, net
- Milestone set to 1.7
This can be done in net.get and net.post by using the defer option then assigning the 'load' listener using glow.events.addListener. We should make it so you can use a similar pattern for loadScript.
-
Stephen Elson September 4th, 2009 @ 02:17 PM
- Milestone changed from 1.7 to 2.0
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
A JavaScript Library