The problem is that you $(".prod-view").click() only initializes the visible content, that is, the rows on page # 1. dataTables inserts and deletes table rows in the DOM and from the DOM to display the pages. So you should use a delegated event handler:
$("#prodlist").on("click", ".prod-view", function() { var href = $(this).attr('href'); $( ".modal-body" ).load( href ); $('#myModal').modal('show')
But, as suggested in the commentary, modals are not included in the system, you do not need to open them programmatically. While you have
<a href="#" data-target="#modal" data-toggle="modal">edit</a>
and a #modal on the page
<div class="modal fade" id="modal"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">This is a modal</h4> </div> <div class="modal-body"> <p>modal</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary" id="submit">submit</button> </div> </div> </div> </div>
The modal will be automatically initialized on all pages. See Demo -> http://jsfiddle.net/9p5uq7h3/
If your only concern is the content of the modal, then simply
$('body').on('show.bs.modal', function() { $(".modal-body").load(url/to/modal/template); });
source share