views:

111

answers:

2

I know there are many questions about jQuery slideToggle "flickering" but I haven't seen any that specifically address this flicker upon page load.

Click here for the working example.

If you click Refresh or click on another datasheet page (under the Datasheets & Product Info section), when the page loads, the hidden div "flashes" the expanded content and then quickly collapses. I notice this in Firefox, not so much in IE or Chrome. What can I do to prevent this? Does this depend on the speed with which the page loads?

Also, please excuse the nightmarish tabulated code. I inherited this from a previous developer. We are planning to go back and correct this in a later phase, but I'm wondering if there is a quick fix for this issue now.

Thanks!

+1  A: 

Maybe display:none for elements like #mover2 ? (of course, that also mean no graceful degradation)

EDIT (a reply to another question) To avoid using #id, #id1, #id2 in your css, you can simply add an extra class to those divs, like hideThis.

Then, in CSS you can just add: .hideThis {display:none; }

Ionut Staicu
A: 

This has to do with the latency of the javascript in Firefox on loading I believe.

I addressed this by, as Ionut Staicu suggests, hiding them in the .CSS which is likely faster than the hide method.

I would also try $('[id=^mover]').hide(); instead of all the individual ones like $('#mover1').hide();

Mark Schultheiss
the flick will be there because the `.hide()` thing is called AFTER dom is ready. So you have to hide it via css :)
Ionut Staicu
You guys are so freaking helpful! Can I pick your brain one more time? Is there a handy short-hand way to type #mover1, #mover2, #mover3...{display:none;} rather than type each selector out individually? On one page I have up to 20 of these things. Thanks so much!
ellenchristine
the $('[id=^mover]').hide(); is the selecter you ask for. It says every "id" attribute that starts with "mover". You could also put them as $("mover1, mover2, mover3").hide(); instead of separate ones (this is the jQuery selector) not sure for the CSS other than what you have.
Mark Schultheiss
One more thing I've noticed: This works in both IE and Firefox, but not Chrome. Do I have to leave the jQuery .hide() function in for Chrome?
ellenchristine
One other suggestion. You could add a "class='moverclass'" to all your mover div's and then use the .moverclass {display:none;} selector.
Mark Schultheiss