Use Jquery's jConfirm like JS's confirm method
I have an anchor on click of which I want to call jquery's jconfirm
method and I am having problem in using it directly as I would do for confirm
method in javascript
<a id="ctl00_CPHMain_lnkDeleteImage" name="ctl00$CPHMain$lnkDeleteImage"
onclick="return confirm('Are you sure ?');">Test</a>
And in jquery I am doing it like this
<a id="ctl00_CPHMain_lnkDeleteImage" name="ctl00$CPHMain$lnkDeleteImage"
onclick="return jConfirm('Are you sure?', 'Update Test')">Test</a>
I want my anchor click to occur when user selects ok
in confirm window
c开发者_StackOverflowurrently I have done it like this in ASP.NET
function ConfirmWindow() {
jConfirm("Are you sure?", "Update Test", function(r) {
if (r == true) {
__doPostBack("ctl00$CPHMain$lnkDeleteImage", "");
}
});
return false;
}
<a onclick="return ConfirmWindow()" id="ctl00_CPHMain_lnkDeleteImage"
name="ctl00$CPHMain$lnkDeleteImage" >Test</a>
You can't. The JavaScript/DOM confirm
dialog is truly modal, which means that it halts script execution and user interaction until the user responds by clicking a button in the confirm dialog.
jConfirm, however, is a JavaScript implementation that overlays the current page content with more content, so it's not modal because it can't halt script execution without blocking user interaction with the "dialog" itself. This means it has to return from the function before the user can respond to the confirm dialog and that's why the callback function is required instead.
精彩评论