Jump to content
markus_ja

Is there a build in javascript "this" variable?

Recommended Posts

Hello,

 

I use jQuery a lot. When passing a function to a jquery function, "this" is used to refere to the current object. Currently, I just use the asm section to access that variable. Is there a more elegant way?

 

e.g.:

jQuery(divMyTable, '#id-amount').each(
    procedure
    var
      this: Variant;
      amount: float;
    begin
      asm @this = this; end; //I would like to avoid using asm section regulary in my project.

      amount := TVariant.AsFloat(jQueryEx(this).text());
      Inc(amount);
      
      jQueryEx(this).text(amount);
    end);

When I write a function, the this variable is used from a different scope. Inlining also doesn't help.

function W3This: variant; inline;

function W3This: variant;
begin
  asm @result = this; end; //Wrong scope
end;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×