Let mobile form declare if/how to auto-focus a field
and for mobile ordering, auto-focus the "units" field when editing a row
This commit is contained in:
parent
6b3e645c12
commit
634a93061b
4 changed files with 27 additions and 10 deletions
|
@ -50,7 +50,8 @@ $(document).on('autocompleteitemselected', function(event, uuid) {
|
|||
|
||||
/**
|
||||
* Automatically set focus to certain fields, on various pages
|
||||
* TODO: this should accept selector params instead of hard-coding..?
|
||||
* TODO: should be letting the form declare a "focus spec" instead, to avoid
|
||||
* hard-coding these field names below!
|
||||
*/
|
||||
function setfocus() {
|
||||
var el = null;
|
||||
|
@ -73,6 +74,21 @@ $(document).on('pageshow', function() {
|
|||
|
||||
setfocus();
|
||||
|
||||
// if current page has form, which has declared a "focus spec", then try to
|
||||
// set focus accordingly
|
||||
var form = $('.ui-page-active form');
|
||||
if (form) {
|
||||
var spec = form.data('focus');
|
||||
if (spec) {
|
||||
var input = $(spec);
|
||||
if (input) {
|
||||
if (input.is(':visible')) {
|
||||
input.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue