title: Sweet Alert not waiting until user clicks ok
body: <p>I am using SweetAlert with Symfony and I want the user to confirm before completing a delete action.</p>
  
  <p>What's happening is when the user clicks the delete button the SweetAlert pops up, then disappears right away and the item was deleted.</p>
  
  <p>I do not want the item deleted until the user clicks ok from the SweetAlert pop up.</p>
  
  <p>Here is my setup.</p>
  
  <p>JS:</p>
  
  <pre><code>function myFunction() {
          swal({
              title: "Are you sure?",
              text: "You will not be able to recover this Job Title!",
              type: "warning",
              showCancelButton: true,
              confirmButtonColor: "#DD6B55",
              confirmButtonText: "Yes, delete it!",
              closeOnConfirm: false,
              closeOnCancel: false
          }, function (isConfirm) {
              if (isConfirm){
                  swal("Deleted!", "Job Title has been deleted.", "success");
              } else {
                  swal("Cancelled", "Job Title was not deleted.", "error");
              }
          });
      };
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;a href="{{ path('setup_jobtitles_delete', {'id': jobTitle.id}) }}" onclick="myFunction()" class="btn btn-white" data-toggle="tooltip" data-toggle="tooltip" data-placement="top" title="Delete"&gt;
      &lt;i class="fa fa-trash"&gt;&lt;/i&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p>How do I make the delete action wait until the user clicks ok?</p>
  
  <p>EDIT: I ended up using <code>$.post</code> and moved the <code>href</code> to a <code>data-</code> like this:</p>
  
  <pre><code> &lt;a href="#" onclick="myFunction(this)" data-url="{{ path('setup_jobtitles_delete', {'id': jobTitle.id}) }}" class="btn btn-white" data-toggle="tooltip" data-toggle="tooltip" data-placement="top" title="Delete"&gt;
                                                                  &lt;i class="fa fa-trash"&gt;&lt;/i&gt;
                                                              &lt;/a&gt;
  function myFunction(btn) {
          var url = $(btn).data('url');
          swal({
              title: "Are you sure?",
              text: "You will not be able to recover this Job Title!",
              type: "warning",
              showCancelButton: true,
              confirmButtonColor: "#DD6B55",
              confirmButtonText: "Yes, delete it!",
              closeOnConfirm: false
          }, function () {
               $.post(url, function(){
                  swal("Deleted!", "Job Title has been deleted.", "success");
                  $(btn).parents('tr').remove();
               });
          });
      };
  </code></pre>