I don’t even know if this is possible but here is an example:
<div id="register">
//bunch of markup including inputs
</div>
Via AJAX I replace the register div, but if there is a focus on a text box inside of the register div, it loses focus when replaces happens. Is there a way to maintain focus?
here is the javascript:
$("#cart_contents input").change(function()
{
$(this.form).ajaxSubmit({target: "#register_container", success: function()
{
}
});
});
I have lots of inputs inside this form, how can I figure out how to refocus
If you get an
IDhandle for the text box, e.g.textbox, when AJAX is complete, call:A more generic solution. Given focusable elements have
IDs, bookend your AJAX stuff like so:Reference focus()jQuery, Using jQuery to test if an input has focus.