Home > Web Front-end > JS Tutorial > Extjs Optimization (2) Universal Implementation of Form Submission

Extjs Optimization (2) Universal Implementation of Form Submission

高洛峰
Release: 2017-02-04 13:21:03
Original
1468 people have browsed it

/** 
* 提交表单 
*/ 
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: "正在提交数据...", 
success: function(c, d) { 
Ext.ux.Toast.msg("操作信息", "成功信息保存!"); 
if (a.callback) { 
a.callback.call(b, c, d); 
} 
}, 
failure: function(c, d) { 
Ext.MessageBox.show({ 
title: "操作信息", 
msg: "信息保存出错,请联系管理员!", 
buttons: Ext.MessageBox.OK, 
icon: "ext-mb-error" 
}); 
if (a.callback) { 
a.callback.call(b); 
} 
} 
}); 
} 
}
Copy after login

It only takes 13 lines of code to use the modified code. The original requires 25-30 lines of code to complete. Example:

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(); 
} 
});
Copy after login

For more Extjs optimization (2) Form form submission universal implementation related articles, please pay attention to the PHP Chinese website!

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