Search |
||
Keeping focusPosted by driscoll on August 11, 2009 at 10:56 AM PDT
A recent user question, which has been repeated enough times to warrant a blog posting. In short: Why am I losing focus when I use the <f:ajax> tag?
Let's imagine you have a form, with two input fields and two output fields:
Why? When you tabbed out of field one, you generated a blur event. This calls an Ajax request, which updates the entire form. That, in turn, removes and re-adds all of the elements in that form - including field 2. With that field (momentarily) gone, the focus is lost. So, how to deal with this? Simple rule: Don't replace the parent element of the element whose focus you want to keep. There's also a simple corollary: Don't update stuff you don't have to.
Here's the changed markup that works:
Questions? Ask below. »
Related Topics >>
Web Applications Comments
Comments are listed in date ascending order (oldest first)
|
||
|
|