Bootstrap Event for modal, executing JS before modal popup

Posted on December 10, 2015 by Suresh Kamrushi in PHP
  

Bootstrap provide some event which can be hook on modal functionality. “show.bs.modal” is a event used to hook a function just befor a modal window popups. Below is an example how you can acheive this using “show.bs.modal”.

//Comment Popop
$("#ShowComment").on("show.bs.modal", function(e) {
var questoinId = $(e.relatedTarget).data('questoinid');
$.ajax({
method: "POST",
url: "<?php echo site_url()?>dashboard/get_comments/"+questoinId
})
.done(function( msg ) {
$("#commentTable").html(msg);
});
});
//Comment Popop

Below are some events available with bootstrap which can be hooked:

bootstrap events

bootstrap events