// 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'));
}
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() {