ACQ return-to-[search/invoice] buttons repair
[transitory.git] / Open-ILS / web / js / ui / default / acq / po / view_po.js
index f3cf4df..4c2a7e7 100644 (file)
@@ -358,15 +358,17 @@ function renderPo() {
     /* if we got here from the search/invoice page with a focused LI,
      * return to the previous page with the same LI focused */
     var cgi = new openils.CGI();
-    if (cgi.param('focus_li')) {
+    var source = cgi.param('source');
+    var focus_li = cgi.param('focus_li');
+    if (focus_li && source) {
         dojo.forEach(
             ['search', 'invoice'], // perhaps a wee bit too loose
-            function(source) {
-                if (document.referrer.match(new RegExp(source))) {
-                    openils.Util.show('acq-po-return-to-' + source);
-                    var newCgi = new openils.CGI({url : document.referrer});
-                    newCgi.param('focus_li', cgi.param('focus_li'));
-                    dojo.byId('acq-po-return-to-' + source + '-button').onclick = function() {
+            function(srcType) {
+                if (source.match(new RegExp(srcType))) {
+                    openils.Util.show('acq-po-return-to-' + srcType);
+                    var newCgi = new openils.CGI({url : source});
+                    newCgi.param('focus_li', focus_li);
+                    dojo.byId('acq-po-return-to-' + srcType + '-button').onclick = function() {
                         location.href = newCgi.url();
                     }
                 }