Confirmation with save and delete button

How to create warning message in javascript with save and delete button? If we use the code

confirm('Do you want to save it?');

We will get a confirmation window ok. How can we make the button text ok as save and reset the other?

+3
source share
3 answers

You cannot change the default javascript method "confirm". But you can override it, for example, with the jQuery UI dialog box:

window.confirm = function (message) {
  var html = "<div style='margin:20px;'><img style='float:left;margin-right:20px;' src='/img/confirm.gif' alt='Confirm'/><div style='display:table;height:1%;'>" + message + "</div></div>";

  $(html).dialog({ closeOnEscape: false,
    open: function (event, ui) { $('.ui-dialog-titlebar-close').hide(); },
    modal: true,
    resizable: false,
    width: 400,
    title: "Confirmation",
    buttons: { 
        "Save": function () {
            //Do what you need
        },
        "Cancel": function () {
            $(this).dialog("close"); 
        } 
    }
  });
}
+3
source

it's impossible

more answers

0
source
  • JS-. , jQuery + UI
  • window.confirm, JS.
  • PROFIT!!!
0

All Articles