From the archives · 2015

Bootstrap Event for modal, executing JS before modal popup

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