Home > Web Front-end > JS Tutorial > Extjs optimization (2) Universal implementation of form submission_extjs

Extjs optimization (2) Universal implementation of form submission_extjs

WBOY
Release: 2016-05-16 17:37:03
Original
1182 people have browsed it
Copy code The code is as follows:

/**
* Submit form
*/
function $postForm( a) {
if (a.formPanel.getForm().isValid()) {
var b = a.scope ? a.scope: this;
a.formPanel.getForm().submit( {
scope: b,
url: a.url,
method: "post",
params: a.params,
waitMsg: "Submitting data...",
success: function(c, d) {
Ext.ux.Toast.msg("Operation information", "Successful information saved!");
if (a.callback) {
a. callback.call(b, c, d);
}
},
failure: function(c, d) {
Ext.MessageBox.show({
title: "Operation Message ",
msg: "Error saving information, please contact the administrator! ",
buttons: Ext.MessageBox.OK,
icon: "ext-mb-error"
});
if (a.callback) {
a.callback.call(b);
}
}
});
}
}

Using the modified code only requires 13 lines of code. The original requires 25-30 lines of code. Example:
Copy code The code is as follows:

saveRecord: function() {
$postForm({
formPanel:this.formPanel,
scope:this,
url: __ctxPath "/basedata/saveStudentDepartment.action ",
params:{},
callback: function(d, f) {
var e = Ext.getCmp("StudentDepartmentGrid");
if (e != null) {
e.getStore().reload();
}
b.close();
}
});
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template