title: Custom confirm dialog in JS or JQuery
body: <p>I have this JavaScript (KnockoutJS) code. I Have a function that in some cases prompt a confirm dialog, and returns the user's answer or "true" if it didn't have to prompt the dialog at all.</p>
  
  <p>The JS regular dialog is ugly and I'd like to create a custom dialog, but I need a kind of modal dialog that <strong>I can get the user's answer</strong> - I don't want to define the next operation (what to do if the user clicks OK) in the dialog itself, because - as you can see in my code - I use the same dialog for many different functions that each has a different behavior so every time the next operation is different.</p>
  
  <pre><code> self.confirmDialog = function () {
         if (condition) {
             return (confirm("text text text"));
         }
         else {
               return true;
         }
    }
  
  
   self.doSomething1 = function () {
       if (self.confirmDialog ()) {
           // do something 1
       }
       // some code
   }
   self.doSomething2 = function () {
       // some code
       if (self.confirmDialog ()) {
           // do something 2
       }
   }
   self.doSomething3 = function () {
       if (self.confirmDialog ()) {
           // do something 3
       }
   }
  </code></pre>