Form表单提交时的遮罩层
程序员文章站
2023-12-21 16:12:10
...
1、Easyui遮罩层(jquery.messager.js)
function saveBackground($form, $grid, url, $dialog){
var validate = $form.form("validate");
if(validate){
$form.form('submit',{
url: url,
onSubmit: function(){
//遮罩层打开
$.messager.progress({
title: '提示',
msg: '数据上传中,请稍候……',
text: ''
});
return true;
},
success: function(redata){
//遮罩层关闭
$.messager.progress('close');
var data = eval('('+redata+')');
if (data.result == "success"){
$.messager.alert('信息提示', data.info,'info');
$.utils.buttonCloseDialog($dialog);
$grid.datagrid('clearSelections');
$grid.datagrid('reload');
} else {
$.messager.alert('信息提示', data.info,'error');
}
}
});
}
}
2、Layui遮罩层(layui.js)
function saveForeground($form, $grid, url,callback){
var flag = $form.validate().form();
if(flag){
$form.form('submit',{
url: url,
layerIndex: -1,//层面标识
onSubmit: function(){
//打开遮罩层
this.layerIndex = layer.load(0);
return true;
},
success: function(redata){
//关闭遮罩层
layer.close(this.layerIndex);
var data = eval('('+redata+')');
if (data.result == "success"){
Global.Message.showSuccess(data.info)
Global.Form.resetForm($form);
$.each($grid,function(i,grid){
if($(grid)){
$(grid).bootstrapTable('refresh');
}
})
if(typeof callback === "function"){
callback();
}
} else {
Global.Message.showError(data.info)
}
}
});
return true;
}else{
Global.Message.validateError()
return false;
}
},