To answer the second question - how to close an existing modal and subsequently open a new one, you need to do three things:
- Add Persist: true to the callback option of the first modal file. According to Eric Martin: โIf true, data will be maintained between modal calls; if false, data will be returned to its original state.
- Add the onClose callback to the first modal module.
- Close the first modal BEFORE the function starts to open the second modal.
So, when you close modal with $. modal.close () is started by onClose , thereby starting the animation and closing the modal. Since persist is true, the next function will be saved . Your function will work, and the second mode will open.
$("#first_modal").modal({ containerId: 'modal_id', persist: true, onClose: function (dialog) { dialog.container.fadeOut(100, function () { dialog.overlay.fadeOut(200, function(){ $.modal.close(); showSecondModal(); }); });
}});
source share