The Javascript "this" keyword in Amber

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

The Javascript "this" keyword in Amber

gcambi
Hi,

Is there a way to 'translate' the 'this' keyword from Javascript
(jQuery) to Amber, for
example in a context like the following:

'input[name=radio]' asJQuery change: [ | v | v := <$(this).val()>.
window alert: v].

BTW, the example code works as it is, so it is more a matter of
curiosity.

--
Gabriele

Reply | Threaded
Open this post in threaded view
|

Re: The Javascript "this" keyword in Amber

Herby Vojčík


gcambi wrote:
> Hi,
>
> Is there a way to 'translate' the 'this' keyword from Javascript
> (jQuery) to Amber, for
> example in a context like the following:
>
> 'input[name=radio]' asJQuery change: [ | v | v :=<$(this).val()>.
> window alert: v].

There is no way, as of now. I think there may be some curry/uncurry
support for this, eventually, so that you can write:

'input[name=radio]' asJQuery change: [ :thisp | | v | v := thisp
asJQuery val. window alert: v ] curryThis.

> BTW, the example code works as it is, so it is more a matter of
> curiosity.

It works, but it is not the advised style. <...> was meant as inline JS
_statement_, not _expression_. So it may as well be that it won't work
in next versions (though <v=$(this).val()> will).

> Gabriele

Herby