I am trying to do all dom manipulations off screen and then make it visible. Which works, except now I have the situation where I am trying to do it with a form which I want to focus on the first input text upon rendering it on the browser.
Something like: myForm.prependTo(myDiv).show().find( input:first ).focus();
Problem is that the focus is being called before the form has finished rendering which is causing the lovely error Can t move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus
How do other web developers handle the similiar situation of manipulating elements off screen and then making it visible? I wish jQuery had something like
myForm.prependTo(myDiv, function() { /* on render code here */ })
I know one way of doing it is setting a timeout and when it fires I put focus on the input, but I feel like that s not really the cleanest way to do things. I know the iframe has an onload event, so I m curious if people usually draw their elements in some hidden iframe and listen for its load event to know when the element has finished rendering? If so could you point me to an example of doing this?
I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....