That is genius Mike, I'm extremely grateful.

It worked perfectly - even with adding my images using jquery, the
total time was ~1.2 secs, which I see as acceptable for 1000 <input>s.

Many thanks once more,

Dan.

PS - if it's not too much trouble, could you explain /why/ it works?
Especially the event.target selector, what's that? I didn't really get
target from the documentation, and what's the 'event' parameter?

thanks.

On 8/21/07, Dan Eastwell <[EMAIL PROTECTED]> wrote:
> 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
>


-- 
Daniel Eastwell

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

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

Reply via email to