>  기사  >  웹 프론트엔드  >  Extjs 최적화 (2) 양식 제출의 보편적 구현

Extjs 최적화 (2) 양식 제출의 보편적 구현

高洛峰
高洛峰원래의
2017-02-04 13:21:031383검색

/** 
* 提交表单 
*/ 
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); 
} 
} 
}); 
} 
}

수정된 코드를 사용하는 데는 13줄의 코드만 필요합니다. 원본을 완료하려면 25~30줄의 코드가 필요합니다. 예:

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

추가 Extjs 최적화를 위해 (2) 양식 양식 제출 범용 구현 관련 기사는 PHP 중국어 웹사이트를 주목해주세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.