Jump to content

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;
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...