Imagine a fairly standard web app page using jQuery and Knockout which uses mostly modal dialogs for editing data. The modal dialogs are created via jQuery UI and everything works. As the page loads, the JS runs, the dialogs open when the button is clicked, do their job, all is fine, great, and peachy.
However, as the page is loading, the elements in the div
s containing the HTML for the modal controls will flash just for a second before the script to turn them into dialogs completes, after which they're once again hidden until the dialog is opened. And yes, this will happen even when the script has been wrapped in the $(document).ready()
call since all that does is prevent manipulation until the DOM has been loaded.
One method which seems to make this go away is to add visibility: hidden;
to the CSS of the class which I assign to my modal div
s which stops the elements form appearing on page load but it also then turns those elements inside the modal control invisible and I have to add the following line to the function which opens it...
$modal.css('visibility', 'visible');
Again, all this seems to work, but I'm wondering if anyone knows a better way to effectively hide all of the inputs and dropdowns, and text inside what will become a modal control on page load than by playing with the CSS when the dialog opens.