One thing I like to do with forms, especially on mobile platforms, is to automatically highlight the first field in the form when it comes in to view. The trick with jQuery Mobile is that with AJAX loading, pre-loading, and BACK/FORWARD buttons, you need to figure out which form is currently in view, and when transitions between forms happen.
Fortunately jQuery Mobile provides us the two facilities we need:
ui-page-activeCSS class gets applied to the
.pageelement that is currently in view.
pageshowevent gets triggered on the document when a page transition has completed to change which page is in view.
1 2 3
Now, after every page transition, if there is a form on the newly-visible page, the first visible input element automatically receives focus. This works across AJAX, non-AJAX, and BACK/FORWARD page transitions.