support cdata wrappers on enclosed html return
[roojs1] / Roo / form / Action.js
index eae17c6..febdb1d 100644 (file)
@@ -8,7 +8,9 @@
  * Fork - LGPL
  * <script type="text/javascript">
  */
+
+// as we use this in bootstrap.
+Roo.namespace('Roo.form');
  /**
  * @class Roo.form.Action
  * Internal Class used to handle form actions
@@ -16,6 +18,7 @@
  * @param {Roo.form.BasicForm} el The form element or its id
  * @param {Object} config Configuration options
  */
+
  
  
 // define the action interface
@@ -32,7 +35,7 @@ Roo.form.Action.CLIENT_INVALID = 'client';
  * Server Validation Failed
  * @const 
  */
- Roo.form.Action.SERVER_INVALID = 'server';
+Roo.form.Action.SERVER_INVALID = 'server';
  /**
  * Connect to Server Failed
  * @const 
@@ -67,6 +70,7 @@ Roo.form.Action.prototype = {
 
     // default connection failure
     failure : function(response){
+        
         this.response = response;
         this.failureType = Roo.form.Action.CONNECT_FAILURE;
         this.form.afterAction(this, false);
@@ -172,6 +176,7 @@ Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
                 }
                 if (!rdata || !rdata.success) {
                     Roo.log(rdata);
+                    Roo.MessageBox.alert(Roo.encode(rdata));
                     return;
                 }
                 var data = rdata.data;
@@ -214,16 +219,15 @@ Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
                     (new Date() * 1) + '' + Math.random());
                     
             } 
-            if (this.form.maskEl) {
-                this.form.maskEl.mask("Saving");
-            }
+            
             
             Roo.Ajax.request(Roo.apply(this.createCallback(), {
                 form:this.form.el.dom,
                 url:this.getUrl(!isPost),
                 method: method,
                 params:isPost ? this.getParams() : null,
-                isUpload: this.form.fileUpload
+                isUpload: this.form.fileUpload,
+                formData : this.form.formData
             }));
             
             this.uploadProgress();
@@ -240,9 +244,7 @@ Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
         if (this.haveProgress) {
             Roo.MessageBox.hide();
         }
-        if (this.form.maskEl) {
-            this.form.maskEl.unmask();
-        }
+        
         
         var result = this.processResponse(response);
         if(result === true || result.success){
@@ -261,9 +263,6 @@ Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
         if (this.haveProgress) {
             Roo.MessageBox.hide();
         }
-        if (this.form.maskEl) {
-            this.form.maskEl.unmask();
-        }
         
         this.response = response;
         this.failureType = Roo.form.Action.CONNECT_FAILURE;
@@ -290,7 +289,13 @@ Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
         }
         var ret = false;
         try {
-            ret = Roo.decode(response.responseText);
+            var rt = response.responseText;
+            if (rt.match(/^\<!--\[CDATA\[/)) {
+                rt = rt.replace(/^\<!--\[CDATA\[/,'');
+                rt = rt.replace(/\]\]--\>$/,'');
+            }
+            
+            ret = Roo.decode(rt);
         } catch (e) {
             ret = {
                 success: false,
@@ -313,9 +318,7 @@ Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
     type : 'load',
 
     run : function(){
-        if (this.form.maskEl) {
-            this.form.maskEl.mask("Loading");
-        }
+        
         Roo.Ajax.request(Roo.apply(
                 this.createCallback(), {
                     method:this.getMethod(),
@@ -325,9 +328,7 @@ Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
     },
 
     success : function(response){
-        if (this.form.maskEl) {
-            this.form.maskEl.unmask();
-        }
+        
         var result = this.processResponse(response);
         if(result === true || !result.success || !result.data){
             this.failureType = Roo.form.Action.LOAD_FAILURE;