var wait = function(id){
var dtd = $.Deferred();
$.post('${resource(dir:'draftPosition',file:'verificationTask')}',{id:id},function(result){
if(result){
dtd.resolve();
}else{
dtd.reject();
}
},'json');
return dtd.promise();
};
$.when(wait(row.id)).fail(function(){
$.messager.alert("警告信息","该用户当前还有任务,不能进行删除操作!","warning");
})
.done(function(){
$.post('${resource(dir:'draftPosition',file:'removeUser')}',{id:row.id,positionId:node.id},function(result){
if (result.success){
$('#dg').datagrid('reload'); // reload the user data
$.messager.show({title: '提示',msg:"删除成功!",timeout:1000});
} else {
$.messager.show({ // show error message
title: '错误',
msg: result.msg
,timeout:1000
});
}
},'json');
});
具体的请到官方网站上查看API