jQuery negatives: dual/triple/quadruple special-case uses for both function calls and method names

View: New views
11 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

Re: jQuery negatives: dual/triple/quadruple special-case uses for both function calls and method names

by SeViR :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Stephan Beal escribió:
> On Aug 16, 7:39 pm, Mitch <goofy...@...> wrote:
>  
>
> An interesting point - don't recommend jQ IF the point of your work is
> teaching JavaScript.
>  
In my courses, I teach using Web Services with JavaScript, AJAX techniques,
and others HTML Rich Application techniques so my target is not JavaScript
learning because it is more difficult teach to a student ALL the
differents *hacks*
for any browsers (events attach, get XMLHttpRequest, ....) so I teach
jQuery.

I teach the difficulties of cross-browsing, the problems, and then I
show the more
clean jQuery method. All the students keeps the mouth opened when they
can see
how anything is more easy :-)

--
Best Regards,
 José Francisco Rives Lirola <sevir1ATgmail.com>

 SeViR CW · Computer Design
 http://www.sevir.org
 
 Murcia - Spain


Re: jQuery negatives: dual/triple/quadruple special-case uses for both function calls and method names

by Dragan Krstic :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



2007/8/16, Glen Lipka <glen@...>:
As a non-programmer, (HTML/CSS only) I understand lt() and gt() mainly because of &lt; and &gt;.
I think those are very easy.  The place I get confused a little is when you can say $("p:gt(4)") and $("p").gt(4) and get the same thing.  Why both?  I suppose the answer is "because some people like it one way and some the other". 

I like this methods and I'm using them a lot. They are very handful when I must to do some operation on subset of elements:

$("p:gt(4)").show().gt(10).css("color","red");

Or, if you need to operate multiple time on same collection:

var my_coll = $("p");
my_coll.gt(3).css("color","red");
my_coll.lt(3).css("color","blue");

This stuff cannot be done by solely in selector expression.

--
Dragan Krstić krdr
http://krdr.ebloggy.com/

Re: jQuery negatives: dual/triple/quadruple special-case uses for both function calls and method names

by Erik Beeson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> $("p:gt(4)").show().gt(10).css("color","red");
>
> Or, if you need to operate multiple time on same collection:
>
> var my_coll = $("p");
> my_coll.gt(3).css("color","red");
> my_coll.lt(3).css("color","blue");
>
> This stuff cannot be done by solely in selector expression.

I'm pretty sure this can be done with filter. In fact, a cursory test
with firebug on jQuery.com suggests it can:

>>> $('p');
[p, p, p.surprise, p, p.download_link, p.download_link, p, p, p]
>>> $('p:gt(2)');
[p, p.download_link, p.download_link, p, p, p]
>>> $('p:gt(2)').gt(4);
[p]
>>> $('p:gt(2)').filter(':gt(4)');
[p]

I'm all in favor of removing gt/lt/eq in favor of the selector version
with filter.

--Erik

Re: jQuery negatives: dual/triple/quadruple special-case uses for both function calls and method names

by Dragan Krstic :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Of course, but I'm in favor of lt gt eq. Maybe 'cause I learned FORTRAN on college ;)

2007/8/17, Erik Beeson <erik.beeson@... >:

> $("p:gt(4)").show().gt(10).css("color","red");
>
> Or, if you need to operate multiple time on same collection:
>
> var my_coll = $("p");
> my_coll.gt(3).css("color","red");
> my_coll.lt(3).css("color","blue");
>
> This stuff cannot be done by solely in selector expression.

I'm pretty sure this can be done with filter. In fact, a cursory test
with firebug on jQuery.com suggests it can:

>>> $('p');
[p, p, p.surprise, p, p.download_link, p.download_link, p, p, p]
>>> $('p:gt(2)');
[p, p.download_link, p.download_link, p, p, p]
>>> $('p:gt(2)').gt(4);
[p]
>>> $('p:gt(2)').filter(':gt(4)');
[p]

I'm all in favor of removing gt/lt/eq in favor of the selector version
with filter.

--Erik



--
Dragan Krstić krdr
http://krdr.ebloggy.com/

Re: jQuery negatives: dual/triple/quadruple special-case uses for both function calls and method names

by Mitchell Waite-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thank you John - from you that means a lot. Speaking of meaning, are
you suggesting I better get moving on this? When you say move it to
the wiki do you mean I can go and set this up on the jq site?

On Aug 16, 8:45 pm, "John Resig" <jere...@...> wrote:

> Great work Mitch - if someone wants to beat me to you, you should move
> this over to the wiki. I'll try to take a stab at it, if I can
> remember.
>
> --John
>
> On 8/16/07, Mitch <goofy...@...> wrote:
>
>
>
>
>
> > I think this is a very stimulating topic - the responses have given me
> > a lot of insights to the frameworks of which jQuery belongs.
>
> > I see there are some big issues here that kind of scare me, the one
> > that stood out to me is the claim that jQurey is not for beginners who
> > don't know the DOM, CSS and JS.
>
> > I would contend that it is precisely the beginner that jQuery appeals
> > to.
>
> > Using myself as a test case - I came in knowing a little bit about JS,
> > a bit more about CSS and pretty much nothing about DOM..
>
> > I had tried to use JS and CSS to do some fancy interface work and
> > really got stuck in the complexities of JS. Then I found JQ and the
> > world rocked for me. Suddenly I could do amazing things with my GUIs.
> > Sure I had holes in my knowledge bank, and its shown in this mailing
> > list, but I think you will admit this is a pretty impressive interface
> > for a beginner to make:
>
> >http://www.whatbird.com/wwwroot/Components/Complete_Search_Tab.html
>
> > I have tons to learn but what a great and fun way to get started!
>
> > I do think there is one hole in the JQ web site and that is there are
> > not enough real life examples.
>
> > To that end I am putting together jQuery Cheat Sheet (TM) (C) How To.
>
> > I plan to make this available for everyone to contibute to. These two
> > How Tos are examples of the format I am proposing to begin with. If
> > anyone has any suggestions would love to hear them. If you have some
> > suggestions for How Tos let me know and I will try and create them. I
> > was thinking of making this into some kind of wiki like system where
> > it would allow poeple to create How Tos that ended up in this standard
> > format when formatted.
>
> >http://www.whatbird.com/wwwroot/Components/jQuery_How_Do_I_not.html
>
> >http://www.whatbird.com/wwwroot/Components/jQuery_How_Do_I_attr.html
>
> > The JQ web site and other sites do a great job on explaining the API
> > (even if most of the examples dont show up correclty in IE7) - whats
> > missing is the practical side of the package. Real world non verbose
> > examples of how to use the important features presented in a non
> > trival but lucid manner, with the key concepts listed for indexing as
> > well as the discussion is key to these working.
>
> > Mitch- Hide quoted text -
>
> - Show quoted text -


Re: jQuery negatives: dual/triple/quadruple special-case uses for both function calls and method names

by Mitchell Waite-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Is this topic changing to the need for removing stuff from jQ? My
intention was to just get opinions about the comment Thor made.

On Aug 17, 1:04 am, "Erik Beeson" <erik.bee...@...> wrote:

> > $("p:gt(4)").show().gt(10).css("color","red");
>
> > Or, if you need to operate multiple time on same collection:
>
> > var my_coll = $("p");
> > my_coll.gt(3).css("color","red");
> > my_coll.lt(3).css("color","blue");
>
> > This stuff cannot be done by solely in selector expression.
>
> I'm pretty sure this can be done with filter. In fact, a cursory test
> with firebug on jQuery.com suggests it can:
>
> >>> $('p');
>
> [p, p, p.surprise, p, p.download_link, p.download_link, p, p, p]>>> $('p:gt(2)');
>
> [p, p.download_link, p.download_link, p, p, p]>>> $('p:gt(2)').gt(4);
> [p]
> >>> $('p:gt(2)').filter(':gt(4)');
>
> [p]
>
> I'm all in favor of removing gt/lt/eq in favor of the selector version
> with filter.
>
> --Erik


Re: jQuery negatives: dual/triple/quadruple special-case uses for both function calls and method names

by John Resig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> I'm all in favor of removing gt/lt/eq in favor of the selector version
> with filter.

That was the original goal, but I actually decided to introduce an
array method into jQuery to solve that problem: .slice(). Now gt/lt/eq
will become:

gt: .slice(Num)
lt: .slice(0,Num)
eq: .slice(Num,1)

Plus slice gives you a ton of extra functionality:
first: .slice(0,1)
last: .slice(-1)
all but first and last: .slice(1,-1)

--John

Re: jQuery negatives: dual/triple/quadruple special-case uses for both function calls and method names

by bmsterling :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I like that, I like that alot!

On 8/17/07, John Resig <jeresig@...> wrote:

> I'm all in favor of removing gt/lt/eq in favor of the selector version
> with filter.

That was the original goal, but I actually decided to introduce an
array method into jQuery to solve that problem: .slice(). Now gt/lt/eq
will become:

gt: .slice(Num)
lt: .slice(0,Num)
eq: .slice(Num,1)

Plus slice gives you a ton of extra functionality:
first: .slice(0,1)
last: .slice(-1)
all but first and last: .slice(1,-1)

--John



--
Benjamin Sterling
http://www.KenzoMedia.com
http://www.KenzoHosting.com

Re: jQuery negatives: dual/triple/quadruple special-case uses for both function calls and method names

by Andy Matthews-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The only concern I have is that this could be yet another mysterious method that someone might not know what it does. Will it work just lke javascript's slice method?


From: jquery-en@... [mailto:jquery-en@...] On Behalf Of Benjamin Sterling
Sent: Friday, August 17, 2007 10:46 AM
To: jquery-en@...
Subject: [jQuery] Re: jQuery negatives: dual/triple/quadruple special-case uses for both function calls and method names

I like that, I like that alot!

On 8/17/07, John Resig <jeresig@...> wrote:

> I'm all in favor of removing gt/lt/eq in favor of the selector version
> with filter.

That was the original goal, but I actually decided to introduce an
array method into jQuery to solve that problem: .slice(). Now gt/lt/eq
will become:

gt: .slice(Num)
lt: .slice(0,Num)
eq: .slice(Num,1)

Plus slice gives you a ton of extra functionality:
first: .slice(0,1)
last: .slice(-1)
all but first and last: .slice(1,-1)

--John



--
Benjamin Sterling
http://www.KenzoMedia.com
http://www.KenzoHosting.com

Re: jQuery negatives: dual/triple/quadruple special-case uses for both function calls and method names

by John Resig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> The only concern I have is that this could be yet another mysterious method
> that someone might not know what it does. Will it work just lke javascript's
> slice method?

Yes, of course - that's the only reason why I'm making this change.

--John

Re: jQuery negatives: dual/triple/quadruple special-case uses for both function calls and method names

by Andy Matthews-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Then by all means...have at it.

-----Original Message-----
From: jquery-en@... [mailto:jquery-en@...] On
Behalf Of John Resig
Sent: Friday, August 17, 2007 10:56 AM
To: jquery-en@...
Subject: [jQuery] Re: jQuery negatives: dual/triple/quadruple special-case
uses for both function calls and method names


> The only concern I have is that this could be yet another mysterious
> method that someone might not know what it does. Will it work just lke
> javascript's slice method?

Yes, of course - that's the only reason why I'm making this change.

--John


< Prev | 1 - 2 | Next >
LightInTheBox - Buy quality products at wholesale price