projects
/
roojs1
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
support cdata wrappers on enclosed html return
[roojs1]
/
Roo
/
form
/
Action.js
diff --git
a/Roo/form/Action.js
b/Roo/form/Action.js
index
fa79e2c
..
febdb1d
100644
(file)
--- a/
Roo/form/Action.js
+++ b/
Roo/form/Action.js
@@
-8,7
+8,9
@@
* Fork - LGPL
* <script type="text/javascript">
*/
* 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
/**
* @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
*/
* @param {Roo.form.BasicForm} el The form element or its id
* @param {Object} config Configuration options
*/
+
// define the action interface
// define the action interface
@@
-32,7
+35,7
@@
Roo.form.Action.CLIENT_INVALID = 'client';
* Server Validation Failed
* @const
*/
* Server Validation Failed
* @const
*/
-
Roo.form.Action.SERVER_INVALID = 'server';
+Roo.form.Action.SERVER_INVALID = 'server';
/**
* Connect to Server Failed
* @const
/**
* Connect to Server Failed
* @const
@@
-67,6
+70,7
@@
Roo.form.Action.prototype = {
// default connection failure
failure : function(response){
// default connection failure
failure : function(response){
+
this.response = response;
this.failureType = Roo.form.Action.CONNECT_FAILURE;
this.form.afterAction(this, false);
this.response = response;
this.failureType = Roo.form.Action.CONNECT_FAILURE;
this.form.afterAction(this, false);
@@
-159,8
+163,24
@@
Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
id : uid
},
method: 'GET',
id : uid
},
method: 'GET',
- success : function(
data
){
+ success : function(
req
){
//console.log(data);
//console.log(data);
+ var rdata = false;
+ var edata;
+ try {
+ rdata = Roo.decode(req.responseText)
+ } catch (e) {
+ Roo.log("Invalid data from server..");
+ Roo.log(edata);
+ return;
+ }
+ if (!rdata || !rdata.success) {
+ Roo.log(rdata);
+ Roo.MessageBox.alert(Roo.encode(rdata));
+ return;
+ }
+ var data = rdata.data;
+
if (this.uploadComplete) {
Roo.MessageBox.hide();
return;
if (this.uploadComplete) {
Roo.MessageBox.hide();
return;
@@
-193,13
+213,12
@@
Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
var method = this.getMethod();
var isPost = method == 'POST';
if(o.clientValidation === false || this.form.isValid()){
var method = this.getMethod();
var isPost = method == 'POST';
if(o.clientValidation === false || this.form.isValid()){
+
if (this.form.progressUrl) {
if (this.form.progressUrl) {
-
- this.findField('UPLOAD_IDENTIFIER').setValue(
+ this.form.findField('UPLOAD_IDENTIFIER').setValue(
(new Date() * 1) + '' + Math.random());
(new Date() * 1) + '' + Math.random());
- }
-
+ }
Roo.Ajax.request(Roo.apply(this.createCallback(), {
Roo.Ajax.request(Roo.apply(this.createCallback(), {
@@
-207,7
+226,8
@@
Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
url:this.getUrl(!isPost),
method: method,
params:isPost ? this.getParams() : null,
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();
}));
this.uploadProgress();
@@
-225,6
+245,7
@@
Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
Roo.MessageBox.hide();
}
Roo.MessageBox.hide();
}
+
var result = this.processResponse(response);
if(result === true || result.success){
this.form.afterAction(this, true);
var result = this.processResponse(response);
if(result === true || result.success){
this.form.afterAction(this, true);
@@
-268,7
+289,13
@@
Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
}
var ret = false;
try {
}
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,
} catch (e) {
ret = {
success: false,
@@
-291,6
+318,7
@@
Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
type : 'load',
run : function(){
type : 'load',
run : function(){
+
Roo.Ajax.request(Roo.apply(
this.createCallback(), {
method:this.getMethod(),
Roo.Ajax.request(Roo.apply(
this.createCallback(), {
method:this.getMethod(),
@@
-300,6
+328,7
@@
Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
},
success : function(response){
},
success : function(response){
+
var result = this.processResponse(response);
if(result === true || !result.success || !result.data){
this.failureType = Roo.form.Action.LOAD_FAILURE;
var result = this.processResponse(response);
if(result === true || !result.success || !result.data){
this.failureType = Roo.form.Action.LOAD_FAILURE;