JSFiddle - React, Tailwind, and code Playground

by joshmoto

HTML

<script src="https://code.jquery.com/jquery-3.4.1.slim.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css">
<div class="modal fade" id="test-modal" tabindex="-1">
  <div class="modal-dialog">
    <form class="modal-content">

      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Test Modal</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>

      <div class="modal-body">

        Try close me and then stop me! If you can...

      </div>

    </form>
  </div>
</div>

JavaScript

$('#test-modal').modal('show');

(document).on('hidden.bs.modal', '#test-modal', function(e) {

	console.log('test');

	alert('test');

  var confirm = confirm("Sure you wanna close this modal?");

  if (confirm == true) {

    // i'm sure, continue closing the modal

  } else {

    // halt closing this modal

  } 

});