DataObjects/core.sql
[Pman.Core] / Pman.Request.js
index 3eb8b97..6eb9ee0 100644 (file)
@@ -30,13 +30,14 @@ var t = new Pman.Request({
 Pman.Request = function(config){
     
     Pman.Request.superclass.constructor.call(this, config);
-    this.request(config);
     
-    if (this.mask && this.maskEl) {
+    if (this.mask) {
+        this.maskEl = this.maskEl || Roo.get(document.body);
         Roo.get(this.maskEl).mask(this.mask);
         
     }
-    
+    this.request(config);
+
 }
 
 Roo.extend(Pman.Request, Roo.data.Connection, {
@@ -73,20 +74,18 @@ Roo.extend(Pman.Request, Roo.data.Connection, {
         this.fireEvent("requestcomplete", this, response, options);
         
         if (this.mask && this.maskEl) {
-            Roo.get(this.maskEl).unmask();
+            Roo.get(this.maskEl).unmask(true);
         }
-        
         var res = this.processResponse(response);
                 
         if (!res.success) { // error!
             if (options.failure) {
                 // failure is handled... - do not show error..
-                if (true === Roo.callback(options.failure, options.scope, [res, options])) {
-                    return;
-                }
+                Roo.callback(options.failure, options.scope, [res, options]);
+                return;
             }
             Roo.MessageBox.hide(); // hide any existing messages..
-            Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error Sending");
+            Roo.MessageBox.alert("Error", res && res.errorMsg ?  res.errorMsg : "Error Sending data");
             return;
         }
         Roo.callback(options.success, options.scope, [res, options]);
@@ -99,13 +98,16 @@ Roo.extend(Pman.Request, Roo.data.Connection, {
         this.fireEvent("requestexception", this, response, options, e);
         var res = Roo.callback(options.failure, options.scope, [response, options]);
         if (this.mask && this.maskEl) {
-            Roo.get(this.maskEl).unmask();
+            Roo.get(this.maskEl).unmask(true);
         }
         if (res !== true) {
             var decode = this.processResponse(response);
-                
-            Roo.MessageBox.hide(); // hide any existing messages..
-            Roo.MessageBox.alert("Error", "Error Sending: " + decode.errorMsg);
+            Roo.log(decode);
+            if (Roo.MessageBox.isVisible()) {
+                alert(decode && decode.errorMsg ?  decode.errorMsg : "Error Sending data - return true from failure to remove message");
+                return;
+            }            
+            Roo.MessageBox.alert("Error", decode && decode.errorMsg ?  decode.errorMsg : "Error Sending data");
         }
     }
 });
\ No newline at end of file