Small fix to avoid ajax hangups after nonexistent element update.
[fa-stable.git] / js / utils.js
index 31a7e7d4988cf6d4ea32d57c480a7793387fb391..877af9ad60cc4eab67c98fe540724e2d56512538 100644 (file)
@@ -56,6 +56,7 @@
 //                             debug(cmd+':'+property+':'+type+':'+id);
                        // seek element by id if there is no elemnt with given name
                          objElement = document.getElementsByName(id)[0] || document.getElementById(id);
+                         if(!objElement) continue;
                  if(cmd=='as') {
                                  eval("objElement.setAttribute('"+property+"',"+data+");");
                          } else if(cmd=='up') {
                  if(mark) mark.style.visibility = 'hidden';
 
                  Behaviour.apply();
+
                  if (errors.length>0)
                        window.scrollTo(0,0);
                        //document.getElementById('msgbox').scrollIntoView(true);
          // Restore focus if we've just lost focus because of DOM element refresh
-                 if(!newwin) { 
-                       setFocus();
-                 }
+                       if(!newwin) { 
+                               setFocus();
+                       }
                }
             },
             false  // do not disable caching