From: Bill Erickson Date: Tue, 13 Oct 2015 15:51:57 +0000 (-0400) Subject: KMAIN-1643 invoice ident focus repairs X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7d0daae14026e2ac983dae5c59d8f139198c311e;p=working%2FEvergreen.git KMAIN-1643 invoice ident focus repairs Invoice vendor ID box loads asynchronously. Give the page a second to load before attempting to focus and sanity check that the DOM node exists before attempting to focus it. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/web/js/ui/default/acq/invoice/view.js b/Open-ILS/web/js/ui/default/acq/invoice/view.js index 283e6f62c3..4dda75c2e7 100644 --- a/Open-ILS/web/js/ui/default/acq/invoice/view.js +++ b/Open-ILS/web/js/ui/default/acq/invoice/view.js @@ -93,7 +93,8 @@ function init2() { // sets the focus to the first element which seems to be the logical place. // This sets the focus when the invoice brief is displayed by the toggle button. // It is also set a few line down for the initial page load. - document.getElementById('dijit_form_ValidationTextBox_0').focus(); + var node = document.getElementById('dijit_form_ValidationTextBox_0'); + if (node) node.focus(); openils.Util.hide(dojo.byId('acq-invoice-summary-small')); } @@ -129,7 +130,12 @@ function init2() { extraCopiesFund.build(); // Set the initial focus field. See comment above for additional notes - document.getElementById('dijit_form_ValidationTextBox_0').focus(); + // On the initial page load, the textbox is generated asynchronously. + // Wrap it in a timeout and be sure the DOM node exists before focusing. + setTimeout(function() { + var node = document.getElementById('dijit_form_ValidationTextBox_0'); + if (node) node.focus(); + }, 1000); } function renderInvoice() {