Skip to content

Commit

Permalink
api.modal.confirm fixed for cross-browser compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzobruni committed Dec 9, 2020
1 parent 83ad41c commit 6b9a6e3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/js/api.library.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,12 @@ api.modal.confirm = function (pMessage, pCallbackMethod, pCallbackParams) {
$("#modal-confirm").find(".modal-body > p").empty().html(pMessage);

$("#modal-confirm").find("[name=confirm]").once("click", function () {
// Close the Modal
$("#modal-confirm").modal('hide');
// Must wait for the async transition to finsh before invoking the callback function that may be a cascade confirm
// Consider refactoring by cloning the confir modal instead.
new Promise(resolve => setTimeout(resolve, 100)).then(() => { pCallbackMethod(pCallbackParams); });
$("#modal-confirm").modal('hide').delay(100).queue(function () {
// https://stackoverflow.com/questions/10860171/run-function-after-delay
pCallbackMethod(pCallbackParams);
$(this).dequeue();
});
});

// Force the modal to re-initialise before displaying in case of cascade confirm modals
Expand Down

0 comments on commit 6b9a6e3

Please sign in to comment.