all my jquery and backbone code is contained in the document.ready function.
But there is a problem with that…
Suppose a div has a white background and after JS code is executed inside doc.ready the background becomes yellow.
The problem is that before the code inside doc ready is executed the user for a fraction of a second actually sees the div in white background
What can I do to prevent this?
The load() event in jQuery is what you want. This will call the background color function once that element has loaded, instead of waiting for the entire document (page) to load.
You mean I should use load instead of doc.ready?
load() event can be sent to any element associated with a URL: images, scripts, frames, iframes, and the window object.
Why you can’t display ‘div’ with yellow background immediately?
cause first the markup is loaded…and then what is inside the doc.ready function.
But if you are going to immediately change it to yellow, why can’t you just set the div to background-color:yellow in CSS?
the color that the div must have is dependent on the data that come in JSON format from the server…it is dynamic.
It maybe white or yellow…that is why I cannot just set it using CSS.
Actually there are 6 divs…and some might be yellow and some might be white…it depends…
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.