[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread MorningZ
There isn't much you can do with that since you can't conditionally code in .show or .hide unless you made a plugin to pass in a true/ false parameter and decide in the plugin, for instance $(#no_defs).conditionalShow($('.def').length == 0); On Apr 16, 4:27 pm, Dragon-Fly999

[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread Joseph Le Brech
or try ndfs=$('#no-defs');($('.def').length == 0) ? ndfs.show() : ndfs.hide(); Date: Thu, 16 Apr 2009 13:54:07 -0700 Subject: [jQuery] Re: Shorten the JQuery code From: morni...@gmail.com To: jquery-en@googlegroups.com There isn't much you can do with that since you can't conditionally

[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread mkmanning
$('#no-defs')[$('.def').length==0?'show':'hide'](); On Apr 16, 1:54 pm, MorningZ morni...@gmail.com wrote: There isn't much you can do with that since you can't conditionally code in .show or .hide unless you made a plugin to pass in a true/ false parameter and decide in the plugin, for

[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread Joseph Le Brech
I'm impressed by the [] brackets, does that eval() the 'hide' and 'show' strings? Date: Thu, 16 Apr 2009 14:08:09 -0700 Subject: [jQuery] Re: Shorten the JQuery code From: michaell...@gmail.com To: jquery-en@googlegroups.com $('#no-defs')[$('.def').length==0?'show':'hide'](); On Apr

[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread Andy Matthews
-en@googlegroups.com Subject: [jQuery] Re: Shorten the JQuery code I'm impressed by the [] brackets, does that eval() the 'hide' and 'show' strings? Date: Thu, 16 Apr 2009 14:08:09 -0700 Subject: [jQuery] Re: Shorten the JQuery code From: michaell...@gmail.com To: jquery-en@googlegroups.com

[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread MorningZ
$('#no-defs')[$('.def').length==0?'show':'hide'](); Whoa so $(...)[show]() is equiv $(...).show() that kinda makes sense thinking about the way arrays work in JS.. slick On Apr 16, 5:08 pm, mkmanning michaell...@gmail.com wrote: $('#no-defs')[$('.def').length==0?'show':'hide'](); On

[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread mkmanning
' strings? Date: Thu, 16 Apr 2009 14:08:09 -0700 Subject: [jQuery] Re: Shorten the JQuery code From: michaell...@gmail.com To: jquery-en@googlegroups.com $('#no-defs')[$('.def').length==0?'show':'hide'](); On Apr 16, 1:54 pm, MorningZ morni...@gmail.com wrote: There isn't much you

[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread mkmanning
[mailto:jquery...@googlegroups.com] On Behalf Of Joseph Le Brech Sent: Thursday, April 16, 2009 4:12 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Shorten the JQuery code I'm impressed by the [] brackets, does that eval() the 'hide' and 'show' strings? Date: Thu, 16 Apr 2009 14:08

[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread Ricardo
That's already in the core :) $('#no-defs').toggle( !$('.def').length ); http://docs.jquery.com/Effects/toggle#switch - ricardo On Apr 16, 5:54 pm, MorningZ morni...@gmail.com wrote: There isn't much you can do with that since you can't conditionally code in .show or .hide unless you made a

[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread Andy Matthews
Yep. I like it, and it's really nice...giving you more options. -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of mkmanning Sent: Thursday, April 16, 2009 4:20 PM To: jQuery (English) Subject: [jQuery] Re: Shorten the JQuery code

[jQuery] Re: Shorten the JQuery code

2009-04-16 Thread Joseph Le Brech
Subject: [jQuery] Re: Shorten the JQuery code From: michaell...@gmail.com To: jquery-en@googlegroups.com Guess it depends on who the next guy is :) On Apr 16, 2:16 pm, Andy Matthews li...@commadelimited.com wrote: I'd be careful with code like that. It is terse, and very elegant