[jQuery] Re: show()ing thousands of divs

2009-10-04 Thread Sid
OK - So I implemented this and the performance sucked on IE so I made some more performance improvements. After a few iterations I think I'm happy with the way it's working. We can complain (to put it mildly) about IE's javascript performance all we want but the useful unintended consequence of t

[jQuery] Re: show()ing thousands of divs

2009-09-28 Thread Mike McNally
On Mon, Sep 28, 2009 at 3:34 PM, Michael Geary wrote: > Mike, the requirement here isn't just to show or hide all 3000 entries in > one fell swoop. Sid needs to be able to show and hide individual entries > depending on a filter. So there's no avoiding looping through all the > entries, whether i

[jQuery] Re: show()ing thousands of divs

2009-09-28 Thread Michael Geary
Mike, the requirement here isn't just to show or hide all 3000 entries in one fell swoop. Sid needs to be able to show and hide individual entries depending on a filter. So there's no avoiding looping through all the entries, whether in JavaScript or on the server. Sid, assuming you want to do thi

[jQuery] Re: show()ing thousands of divs

2009-09-28 Thread Mike McNally
> @Mike M. > You're still looping through 3000 jQuery objects and invoking the > setClass() method. I haven't tried it but I suspected it will take > roughly the same time as the show() method. It does seem logical that > the actual showing of the div will be faster if the browser does it > native

[jQuery] Re: show()ing thousands of divs

2009-09-28 Thread Sid
@Mike M. You're still looping through 3000 jQuery objects and invoking the setClass() method. I haven't tried it but I suspected it will take roughly the same time as the show() method. It does seem logical that the actual showing of the div will be faster if the browser does it natively. The ques

[jQuery] Re: show()ing thousands of divs

2009-09-28 Thread William Chang
For 3000 divs and a lot more in the future, then I recommend you do an AJAX to load the content when the user scrolls down. Examples: Slashdot (slashdot.org) Google Reader I know there are jQuery plugins to help you load on scroll, please Google. Good Luck, William Chang http://www.williamchang

[jQuery] Re: show()ing thousands of divs

2009-09-28 Thread Raymond Ho
3000 divs are freaking huge. it would be better to do it in ajax and load them by chunks instead of putting it all in one huge HTML page. On Sep 28, 6:17 pm, "ryan.j" wrote: > presumably the HTML for these ~3k records are being generated server- > side somewhere - can you not split/group the res

[jQuery] Re: show()ing thousands of divs

2009-09-28 Thread ryan.j
presumably the HTML for these ~3k records are being generated server- side somewhere - can you not split/group the results before they hit the browser? On Sep 28, 3:36 am, Sid wrote: > Thanks, guys. > > Michael G., your solution worked like a charm. setTimeout seems to > mess with the context ("

[jQuery] Re: show()ing thousands of divs

2009-09-28 Thread DBJDBJ
@sid Can we have the url to the page which shows your "solution" ? -- DBJ ps: an simple generic and reusable "async worker" : function do_async( callback , optional_host, optional_microseconds ) { var that = optional_host || this ; var timer_id = window.setTimeout ( function (

[jQuery] Re: show()ing thousands of divs

2009-09-27 Thread Mike McNally
> Mike M., > Interesting suggestions to use CSS. But even with the CSS approach, I > doubt if performance will be any better. Looping through each of the > 3000 divs and calling $(this).show() or $(this).addClass('showing') > will probably take the same amount of time. That;'s almost certainly wr

[jQuery] Re: show()ing thousands of divs

2009-09-27 Thread Sid
Thanks, guys. Michael G., your solution worked like a charm. setTimeout seems to mess with the context ("this" is not recognized within the function). But that was a minor problem. I just assigned "this" to a global variable and used that variable inside setTimeout's function. A couple of other s

[jQuery] Re: show()ing thousands of divs

2009-09-27 Thread Mike McNally
If there's a need to selectively show particular elements out of a large number, something to try while experimenting with performance improvements is to construct a CSS block dynamically and then update it. You'd put together the CSS as a stream of "#randomDiv0021 { display: block; }" CSS stateme

[jQuery] Re: show()ing thousands of divs

2009-09-27 Thread Michael Geary
> You would expect the "waitingdiv" to appear instantaneously > because the bottleneck is in show()ing all 3000 divs. But for > some reason it takes a really long time for it to show up. > And then it's gone in a flash and all 3000 divs appear. That's because the browser doesn't refresh the page w

[jQuery] Re: show()ing thousands of divs

2009-09-27 Thread Mike McNally
Give your divs a class, and surround with a div. Use a CSS file that looks something like this: #containerDiv.showing .entityDiv { display: block; } #containerDiv.hiding .entityDiv { display: none; } Now when you want to show your entity divs, you can just say $('#containerDiv').removeClass(