jquery chaining

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

jquery chaining

go2ghana
Hi,
in order to support the first (and in this case only) argument to css be
an object I changed the extern to

     function css<T>( prop : T, ?value : String ) : String;

which works well.

But later I found that it still breaks chaining which is possible with
native jquery like:

$('#content-slider-title-'+id).css({ opacity : 0 }).animate ...

so I changed the extern to:

     function css<T>( prop : T, ?value : String ) : Dynamic;

which works but I wonder if there is a way to do this better since the
return value is
JQuery object if I use it to set the value and String if I use it to get
the value.

Cordially,
Axel

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: jquery chaining

Nicolas Cannasse
Le 21/06/2011 11:02, Axel Huizinga a écrit :
> Hi,
> in order to support the first (and in this case only) argument to css be
> an object I changed the extern to

The way jQuery works (one method for both getter AND setter) is not
compatible with haXe type system, so chaining is limited to methods that
are not getters.

Nicolas


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: jquery chaining

Tony Polinelli
OT 

i was thinking about jquery. It would be good to be able to have package level functions and maybe make

function J(query:String):{  return new JQuery(query); }


This might mean we could have:

$('#content-slider-title-'+id).css({ opacity : 0 }).animate 

go to:

J('#content-slider-title-'+id).css({ opacity : 0 }).animate

which is slightly nicer - especially when you have many $(queries). I think package level functions are proposed? (cant remember if i've already asked about this) 






On Tue, Jun 21, 2011 at 8:59 PM, Nicolas Cannasse <[hidden email]> wrote:
Le 21/06/2011 11:02, Axel Huizinga a écrit :

Hi,
in order to support the first (and in this case only) argument to css be
an object I changed the extern to

The way jQuery works (one method for both getter AND setter) is not compatible with haXe type system, so chaining is limited to methods that are not getters.

Nicolas



--
haXe - an open source web programming language
http://haxe.org



--
Tony Polinelli
http://touchmypixel.com

--
haXe - an open source web programming language
http://haxe.org