不确定这是否是全部,但这部分:
if (JobHander.MaxInstances == 0) {
jConfirm('Continue?', 'Current Maximum Instances', function (ans) {
if (!ans)
return;
});
}
可能没有做你想做的事。它正在退出function(ans) { ... }
函数,而您可能想退出整个处理程序,即$("#UpdateJobHandler").click(function () { ... }
。如果是这样,您需要执行与下面类似的操作 - 即,将整个内容放入function(ans) { ... }
,返回后。可能最好分成更小的函数。
编辑:沿着这些思路:
function afterContinue() {
var json = $.toJSON(JobHander);
$.ajax({
// ... all other lines here ...
});
}
if (JobHander.MaxInstances == 0) {
jConfirm('Continue?', 'Current Maximum Instances', function (ans) {
if (ans) {
afterContinue();
}
});
}
你可以为所有的做类似的事情success
功能。
另一个例子,你可以重写Instances
像这样检查:
function afterInstances() {
var JobHandlerNew = getJobHandler();
JobHandlerNew.FinalUpdate = "Yes";
// ... and everything under else branch ...
}
if (alertM == "Instances") {
jConfirm(message, 'Instances Confirmation?', function (answer) {
if (answer) {
afterInstances();
}
});
}
重要 - 重命名方法(afterContinue
, afterInstances
, ...) 拥有一些对将来阅读本文的人有用的名称。