Skip to content

Commit 0ff9c04

Browse files
committed
changed confirm modal to take callback function and params
1 parent 80e2971 commit 0ff9c04

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

src/js/api.library.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -534,15 +534,15 @@ API - Library - Modal
534534
api.modal = {};
535535

536536
/**
537-
* Pop a Confirm Modal in Bootstrap
538-
* @param {*} pMessage
539-
* @param {*} pCallbackMethod
540-
* @param {*} pCallbackParams
541-
* @param {*} pIconType
542-
* @param {*} pShowCancelMessageType
543-
* @param {*} pCancelMessage
544-
*/
545-
api.modal.confirm = function (pMessage, pCallbackMethod, pCallbackParams, pIconType, pShowCancelMessageDialogType, pCancelMessage) {
537+
* Pop a Confirm Modal in Bootstrap
538+
* @param {*} pMessage
539+
* @param {*} pCallbackMethod
540+
* @param {*} pCallbackParams
541+
* @param {*} pIconType
542+
* @param {*} pCancellationCallbackMethod
543+
* @param {*} pCancellationCallbackParams
544+
*/
545+
api.modal.confirm = function (pMessage, pCallbackMethod, pCallbackParams, pIconType, pCancellationCallbackMethod, pCancellationCallbackParams) {
546546
// Set the body of the Modal - Empty the container first
547547
var msgObj;
548548
if (typeof pMessage == "string") {
@@ -588,16 +588,14 @@ api.modal.confirm = function (pMessage, pCallbackMethod, pCallbackParams, pIconT
588588
});
589589

590590
$("#modal-confirm").find("[name=cancel-confirm]").once("click", function () {
591-
$("#modal-confirm").modal('hide');
592-
if (pShowCancelMessageDialogType == "success") {
593-
api.modal.success(pCancelMessage);
594-
} else if (pShowCancelMessageDialogType == "warning") {
595-
api.modal.warning(pCancelMessage);
596-
} else if (pShowCancelMessageDialogType == "information") {
597-
api.modal.information(pCancelMessage);
598-
} else if (pShowCancelMessageDialogType == "error") {
599-
api.modal.error(pCancelMessage);
600-
}
591+
// Must wait for the async transition to finsh before invoking the callback function that may be a cascade confirm
592+
$("#modal-confirm").modal('hide').delay(100).queue(function () {
593+
// https://stackoverflow.com/questions/10860171/run-function-after-delay
594+
if (pCancellationCallbackMethod != null) {
595+
pCancellationCallbackMethod(pCancellationCallbackParams);
596+
$(this).dequeue();
597+
}
598+
});
601599
});
602600

603601
$("#modal-confirm").modal("show");

0 commit comments

Comments
 (0)