LP#1284864 propagate patron barcode to advanced hold options (repair)
authorBill Erickson <berick@esilibrary.com>
Fri, 28 Feb 2014 19:25:56 +0000 (14:25 -0500)
committerBill Erickson <berick@esilibrary.com>
Fri, 28 Feb 2014 19:25:56 +0000 (14:25 -0500)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/js/ui/default/opac/staff.js

index be803c9..8dd97fb 100644 (file)
@@ -27,6 +27,13 @@ function no_hold_submit(event) {
     return true;
 }
 function staff_hold_usr_barcode_changed(isload) {
+
+    if (!document.getElementById('place_hold_submit')) {
+        // in some cases, the submit button is not present.
+        // exit early to avoid needless JS errors
+        return;
+    }
+
     if(typeof xulG != 'undefined' && xulG.get_barcode_and_settings) {
         var cur_hold_barcode = undefined;
         var barcode = isload;
@@ -99,10 +106,12 @@ function staff_hold_usr_barcode_changed(isload) {
         // barcode if clicked.  This is needed when the patron barcode
         // is manually entered (i.e. the staff client does not provide one).
         var adv_link = document.getElementById('advanced_hold_link');
-        var href = adv_link.getAttribute('href').replace(
-            /;staff_barcode=[^;\&]+|$/, 
-            ';staff_barcode=' + encodeURIComponent(cur_hold_barcode));
-        adv_link.setAttribute('href', href);
+        if (adv_link) { // not present on MR hold pages
+            var href = adv_link.getAttribute('href').replace(
+                /;staff_barcode=[^;\&]+|$/, 
+                ';staff_barcode=' + encodeURIComponent(cur_hold_barcode));
+            adv_link.setAttribute('href', href);
+        }
 
         // Ok, now we can allow submitting again, unless this is a "true" load, in which case we likely have a blank barcode box active
         if (isload !== true)