Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Dear Experts,

I want to know how and where i use bootstrap dialog box in following script.

PLZ HELP ME.

Java
<script>

  $('body').delegate("#delete","click",function(){
      var IdDelete = $(this).attr("idd");

      if(confirm("Are you sure to delete this category")){
      {
          $.ajax(
              {
                  url:"delt.php",
                  type:"POST",
                  data:{
                      deletes:1,
                      id:IdDelete
                  },
                  success:function(){}

              });
          $(this).parents(".del_cat").animate({opacity:"hide"},"slow");
      }
      }
  });

</script>
Posted
Comments
George Jonsson 29-Oct-15 18:59pm    
You are not using Bootstrap at all here, so you your question is not clear.
Palash Mondal_ 30-Oct-15 0:39am    
Your question is not clear. Could you pls add more details to it like what type of bootstrap dialog box is it?, etc.
Nathan Minier 30-Oct-15 7:59am    
You would have to write your own method that will generate a modal confirm and return the response from the user. The vanilla JavaScript confirm() will always open a browser default alert.

1 solution

You can do this way. Please check

<div id="confirmModal" class="modal fade" style="background-color: #fff">
<div class="modal-body">
Are you sure?
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-primary" id="ok">Delete</button>
<button type="button" data-dismiss="modal" class="btn">Cancel</button>
</div>
</div>


<script type="text/javascript">
        var IdDelete = 0;
        $('#delete').on('click', function (e) {
            var attr = $(this).attr('data-val');
            IdDelete = attr;

            e.preventDefault();
            $('#confirmModal').modal("show")

           
        });       


        $('#ok').on('click', function (e) {
           
            if (IdDelete > 0) {

                $.ajax(
                 {
                     url: "delt.php",
                     type: "POST",
                     data: {
                         deletes: 1,
                         id: IdDelete
                     },
                     success: function () { }

                 });
                $(this).parents(".del_cat").animate({ opacity: "hide" }, "slow");


            }
            // Hide and reset valu

            console.log(IdDelete);
            $('#confirmModal').modal("Hide")
            IdDelete = 0;

           
        });

    </script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900