Is there a simple way to have the callback execute within a particular
scope?

Here is what I would like to do:

MyObj = function() {
  var something;
  return {
    init: function() { ... },
    performAjax : function(){
      NameSpace.Page.AjaxProMethod(params, this.ajaxCallback);
    },
    ajaxCallback : function(res){
      something = res.value;
      this.anotherMethod();
    },
    anotherMethod : function() {....}
  }
}

"this.anotherMethod()" will blow up because "this" doesn't refer to
MyObj because the function was executed in a different scope.

I'm sure my syntax is off, but hopefully  you get the point. In the
Yahoo UI you can listen to events and what not while passing in the
scope like:

Something.addListener(window, 'load', 'callbackfunctin', this, true);

'this' is a parameter you pass, and the last parameter 'true' means
that 'callbackfunction' will be called in the scope of 'this'.

It would be great to have something like this in AjaxPro, maybe
something like:
NameSpace.Page.Method.(parameters, <function> callback, <object>
scope);
...or something like that.

I'm just bitching though..I've worked around it many, many times, it
just makes the JavaScript a little uglier.

Reference:
http://developer.yahoo.com/yui/docs/event/YAHOO.util.Event.html#addListener


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Ajax.NET Professional" group.

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]

For more options, visit this group at http://groups.google.com/group/ajaxpro

The latest downloads of Ajax.NET Professional can be found at 
http://www.ajaxpro.info/

Don't forget to read my blog at http://weblogs.asp.net/mschwarz/
-~----------~----~----~----~------~----~------~--~---

Reply via email to