Created
March 13, 2012 19:44
-
-
Save tncbbthositg/2031107 to your computer and use it in GitHub Desktop.
Confirming action with a popup...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage examples | |
// | |
// Calls the default asp.net event for the control | |
// OnClientClick = "return confirmAction('Are you sure?', this);" | |
// | |
// Uses your own function | |
// OnClientClick = "return confirmAction('Are you sure?', function() { window.alert('No Way!'); });" | |
// | |
// Uses built in browser confirmation | |
// OnClientClick = "return confirmAction('Are you sure?');" | |
function confirmAction(message, delegate) { | |
if (typeof (delegate) === "undefined") | |
return window.confirm(message); | |
var action; | |
if (typeof (delegate) === "function") | |
action = delegate; | |
else if (typeof (delegate) === "object") | |
action = function () { __doPostBack(delegate.name, ''); }; | |
$("<div>" + message + "</div>").dialog({ | |
modal: true, | |
draggable: false, | |
buttons: { | |
"OK": function () { $(this).dialog("close"); action(); }, | |
"Cancel": function () { $(this).dialog("close"); } | |
}, | |
title: "Are you Sure?" | |
}); | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment