I am using a jquery plugin for alerts given below:-
function alertWithNewWindow(title, content, icon, newWindow) {
$.alert.open({
title: title,
content: content,
icon: icon,
draggable: true
});
}
I want to add a callback to above function so that when user click on "ok" button of alert-box then page will redirect to the given path.
$(window.location.replace(newWindow));
I have tried below code but its not redirecting.
function alertWithNewWindow(title, content, icon, newWindow) {
$.alert.open({
title: title,
content: content,
icon: icon,
draggable: true
}, function () {
$(window.location.replace(newWindow));
}
);
}
I am guessing you are using this plugin.
After reading the Callback doc section I think this code should work out for you:
function alertWithNewWindow(title, content, icon, newWindow) {
$.alert.open({
title: title,
content: content,
align: 'center',
icon: icon,
maxHeight: 160,
draggable: true,
callback: function(){
$(window.location.replace(newWindow));
}
);
}