I have a column in my table that is a long string. So i'm trying to show it in a popup modal.
When i click the button to launch the modal, the page just refreshes and nothing is even printed to console.
HTML of Modal:
<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 id="modalTitle"></h3>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
</div>
</div>
Here is snippet in DataTable creation.
{ data: 'Journal',
render: function(data, type, row) {return '<button class="btn btn-primary" data-toggle="modal" data-Journal="'+data+'" data-target="#myModal">'+"Details"+'</button>'} },
The modal show event. Nothing is printed in console so i'm guessing the error is before here.
$("#myModal").on('show.bs.modal', function (e) {
var triggerLink = $(e.relatedTarget);
var journal = triggerLink.data("Journal");
console.log(e.relatedTarget);
console.log(journal);
$("modalTitle").text("Title");
$(this).find(".modal-body").html("<h5>"+journal+"</h5>");});
Try changing your button to type = button as its default is submit'
Since you didn't provide any relevant details regarding your use case, I've made up my own example, which delivers major idea, though: