1

I'm working with modal bootstrap and bootbox.js

At below demo, when you open modal and the click delete, modal will show. Now my question how to set modal-backdrop after I click delete button?

$('.delete').on('click', function()
{
  bootbox.dialog(
  {
    message: "Are you sure you want to delete this?</b>",
    title: "<i class='glyphicon glyphicon-trash'></i> Delete",
    buttons:
    {
      success:
      {
        label: "No",
        className: "btn-success",
        callback: function()
        {
          $('.bootbox').modal('hide');
        }
      },
      danger:
      {
        label: "Delete",
        className: "btn-danger",
        callback: function()
        {
          $('#'+ID).click(function()
          {
            return false;
          });

          $.ajax(
          {
            type: "POST",
            url: "deleteNews",
            data:
            {
              ID: ID,
              datas: datas
            },
            success: function(msg)
            {
              if(msg == "newsDeleted")
              {
                $('tr#'+ID).fadeOut('slow', function()
                {
                  $(this).remove();

                  $(".tNewsticker tr").find(".up, .up i, .down, .down i").css({
                    "pointer-events": "auto",
                    "color": "#7b7b7b"
                  });

                  $(".tNewsticker tr:first").find(".up, .up i").css({
                    "pointer-events": "none",
                    "color": "#e7e7e7"
                  });

                  $(".tNewsticker tr:last").find(".down, .down i").css({
                    "pointer-events": "none",
                    "color": "#e7e7e7"
                  });
                });

                buttonClicked();
                $.simplyToast('success', 'News has been deleted');
              }
            }
          });
        }
      }
    }
  });
});
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/5.5.2/bootbox.min.js"></script>
</head>
<body>

<div class="container">
  <h2>Modal Example</h2>
  <!-- Trigger the modal with a button -->
  <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">
          <p>Some text in the modal.</p>
          <button class="delete">Delete</button>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
      
    </div>
  </div>
  
</div>

</body>
</html>
Tieson T.
  • 20,774
  • 6
  • 77
  • 92
HiDayurie Dave
  • 1,791
  • 2
  • 17
  • 45

0 Answers0