First off, this is functioning much better than before. Good work.

In the click handler you bind to the h1 you have a few areas where you
could optimize your code.

First you declare a var named outerchild like this:
var outerid = $(this).parent().attr("id");
var outerchild = $('#' + outerid + '-details');

Then later you use outerchild again but you wrap it in another jQuery object.

$(outerchild)

This isn't necessary and I often times name my jQuery object vars with
a $ to remind me it is the jQuery object and not just the DOM node.

var outerid = $(this).parent().attr("id");
var $outerchild = $('#' + outerid + '-details');

Now you can just use $outerchild.attr(...).

Moving on ... there is a handy method called is that lets you test if
the object is something. So lets look at this particular if statement
and see how it can be written using the is method.

As you have it now:
if ($(outerchild).attr("class").indexOf('outeropen') == -1) {

Using the is method:
if ( !$outerchild.is('.outeropen') ) {

Or you could also use the ':hidden' selector like this:
if ( $outerchild.is(':hidden') ) {

Hope that helps optimize the code a little. :)

--
Brandon Aaron


On 4/3/07, Andy Matthews <[EMAIL PROTECTED]> wrote:

I've made some additions and updates to the code I posted last week:
http://www.commadelimited.com/uploads/psychic/

I wondered if you all would mind looking over it to see if it can be
improved. I've got the functionality the way I like it, but you all
know jQuery way better than I do. So...any suggestions you feel like
making would be welcomed.



Andy Matthews
Senior Coldfusion Developer
Office:  877.707.5467 x747
Direct:  615.627.9747
Fax:  615.467.6249
[EMAIL PROTECTED]
www.dealerskins.com


Reply via email to