This is a question for the question I asked yesterday. I have another problem related to jquery promises.
function setOverrides2() {
var dfd = new $.Deferred();
return dfd.promise();
}
function overrideDialog1() {
var deferred = new $.Deferred();
ConfirmMessage.onConfirmYes = function() {
ConfirmMessage.hideAll();
deferred.resolve();
}
ConfirmMessage.onConfirmNo = function() {
ConfirmMessage.hideAll();
deferred.reject();
}
ConfirmMessage.showConfirmMessage("Do you wish to override primary eligibility?");
return deferred.promise();
}
function overrideDialog2() {
var deferred = new $.Deferred();
ConfirmMessage.onConfirmYes = function() {
ConfirmMessage.hideAll();
deferred.resolve();
}
ConfirmMessage.onConfirmNo = function() {
ConfirmMessage.hideAll();
deferred.reject();
}
ConfirmMessage.showConfirmMessage("Do you wish to override secondary eligibility?");
return deferred.promise();
}
setOverrides2().done(function(data) {
overrideDialog().then(overrideDialog2()).then(function() {
alert("test");
});
});
As shown above, when I use done (), it works fine, but when I use then (), it shows both dialogs at the same time. I want to be able to use reject () to break the chain the first time the user clicks the No button (determined by the onConfirmNo () callback).
The commented section .done () waits for the completion of one dialog before starting the next, but does not cancel processing if the user clicks "No" in the first dialog box.
I think that I have almost all of this right, so if anyone can help with this last piece of the puzzle, I would really appreciate it.
Jason