I have the following code,
var targetUrl = $(this).attr("href");
$("#leaving-dialog").dialog({
buttons: {
"No, I want to stay here": function () {
$(this).dialog("close");
},
"Yes, that's okay": function () {
window.location.href = targetUrl;
}
}
});
which basically makes one of the buttons send the user somewhere. What I want it to do, is open the link in a new window or tab and then close the modal (as they will still have the original page open).
Any idea how I could resolve this?
Use
window.open(targetUrl);instead ofwindow.location.href, and add the line toclosethe dialog after that.Here’s an example fiddle (using some of the example
dialogcode from the jQuery UI docs, and I haven’t included the CSS files, so it doesn’t look like a dialog!)