Thanks for the reply, Mike,

The thinking behind it is not to add the button images using
javascript, so that if you don't have javascript, you don't have
useless and confusing buttons.

I'll try your form event handle, so thanks for that,

Dan.

On 8/21/07, Michael Geary <[EMAIL PROTECTED]> wrote:
>
> > From: Dan Eastwell
> > I'm doing an order form for a bookstore. The order form has
> > over 500 items in it, so jquery runs slowly...
>
> Can't you do any of this on the server? All of the code generation - the IMG
> tags and the zebra striping - would cost next to nothing while the page is
> being generated on the server. And if the page is gzipped it wouldn't even
> take much extra download time.
>
> Then, instead of binding event handlers to all of the individual buttons,
> just bind a single event handler to the parent form:
>
>    $('#order_form').click( function( event ) {
>       var $target = $(event.target);
>       if( $target.is('img.increment') ) return change( 1 );
>       if( $target.is('img.decrement') ) return change( -1 );
>
>       function change( by ) {
>          var $qty = $target.parent('td').find('[EMAIL PROTECTED]');
>          var n = +$qty.val() + by;
>          if( n >= 0 ) $qty.val( n );
>          return false;
>       }
>    });
>
> Even if you have to do the code generation in JavaScript, you can use this
> technique to eliminate all the individual event binding and cut the
> JavaScript load time overhead to virtually nothing.
>
> Let us know if the JavaScript code generation is really mandatory - I saw
> the other replies but there are still a few remaining tricks to speed it up.
>
> -Mike
>
>


-- 
Daniel Eastwell

Portfolio and articles:
http://www.thoughtballoon.co.uk

Blog:
http://www.thoughtballoon.co.uk/blog

Reply via email to