Sharepoint - Close modal popup opened using SP.UI.ModalDialog.ShowPopupDialog(url)
Try using commonModalDialogClose.
Create function to close popup or directly call method.
function CloseDlg() {
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.Cancel);
}
Or try to hide using class.
$('.CloseSPPopUp').click(function(){
window.top.CloseSPUIPopoup();
});
function CloseSPUIPopoup{
$(".ms-dlgContent").hide();
}
Use dialogReturnValueCallback option
var options = SP.UI.$create_DialogOptions();
options.url = '/_layouts/mySolution/myPage.aspx';
options.width = 500;
options.height = 400;
options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);
SP.UI.ModalDialog.showModalDialog(options);
function CloseCallback(result, target) {
//Your code
}
Once I closed my modal in the following way
var closeLoading = function() {
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function() {
SP.UI.ModalDialog.commonModalDialogClose(1, 1);
});
};
So write the following line of code in your button click handler.
SP.UI.ModalDialog.commonModalDialogClose(1, 1);