[jquery] JQuery confirm dialog

Possible Duplicate:
Yes or No confirm box using jQuery

I see a lot of examples here about replacements for jQuerys standard confirm dialog but don't understand any of them.

If I want to pop-up a confirm dialog using jQuery or jQueryUI. How can i do it and retrieve what button the user clicked ?

Surely there must be a simple way to set up a confirm dialog like an alert("Something!"); command.

Add two buttons to it and set a call back function on yes or no ?

This question is related to jquery jquery-ui confirm

The answer is


Have you tried using the official JQueryUI implementation (not jQuery only) : ?


You can use jQuery UI and do something like this

Html:

<button id="callConfirm">Confirm!</button>

<div id="dialog" title="Confirmation Required">
  Are you sure about this?
</div>?

Javascript:

$("#dialog").dialog({
   autoOpen: false,
   modal: true,
   buttons : {
        "Confirm" : function() {
            alert("You have confirmed!");            
        },
        "Cancel" : function() {
          $(this).dialog("close");
        }
      }
    });

$("#callConfirm").on("click", function(e) {
    e.preventDefault();
    $("#dialog").dialog("open");
});

?


Examples related to jquery

How to make a variable accessible outside a function? Jquery assiging class to th in a table Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Getting all files in directory with ajax Bootstrap 4 multiselect dropdown Cross-Origin Read Blocking (CORB) bootstrap 4 file input doesn't show the file name Jquery AJAX: No 'Access-Control-Allow-Origin' header is present on the requested resource how to remove json object key and value.?

Examples related to jquery-ui

How to auto adjust the div size for all mobile / tablet display formats? jQuery not working with IE 11 JavaScript Uncaught ReferenceError: jQuery is not defined; Uncaught ReferenceError: $ is not defined Best Practice to Organize Javascript Library & CSS Folder Structure Change table header color using bootstrap How to get HTML 5 input type="date" working in Firefox and/or IE 10 Form Submit jQuery does not work Disable future dates after today in Jquery Ui Datepicker How to Set Active Tab in jQuery Ui How to use source: function()... and AJAX in JQuery UI autocomplete

Examples related to confirm

Confirm deletion using Bootstrap 3 modal box JQuery confirm dialog javascript popup alert on link click JavaScript Form Submit - Confirm or Cancel Submission Dialog Box How to show the "Are you sure you want to navigate away from this page?" when changes committed? Javascript Confirm popup Yes, No button instead of OK and Cancel