[EMAIL PROTECTED] schrieb:
> "Joe Hudson" <[EMAIL PROTECTED]> writes:
>
>   
>> I can’t figure out how to access “this” in the event method of
>> Rpc.callAsync… I’ve looked at RPC_1-6 and can’t seen any mention of this.
>>
>>     rpc.callAsync(
>>      function(result, ex, id) {
>>                      if (ex == null) {
>>                              alert(this); // this isn’t my class
>>                              // how can I access my class?
>>                              // I would like to call this._myMethod();
>>                      }
>>      });
>>     
>
> Nope, that one doesn't have a provision like addEventListener does, so you'll
> have to use a closure:
>
>     var _this = this;
>     rpc.callAsync(
>       function(result, ex, id) {
>                       if (ex == null) {
>                               alert(_this);
>                       }
>       });
>
> Derrell
>
>   
As an alternative you could also write

    rpc.callAsync(
        qx.lang.Function.bind(function(result, ex, id) {
                if (ex == null) {
                        alert(_this);
                },
        }, this));


The bind function does the same as the closure from Derrell's solution.


Best Fabian


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to