Here's my solution (leveraging a few above) that makes use of BS3's own structure to re-instate the old remote loading behaviour. It should be seamless.
I'm going to keep the code variable heavy and descriptive to keep things understandable. I'm also assuming the presence of JQuery. Javascript heavy lifter types will handily streamline the code.
For reference here's a link that invokes a BS3 modal:
<li><a data-toggle="modal" href="terms.html" data-target="#terms">Terms of Use</a></li>
In youre Javascript you're going to need the following.
// Make sure the DOM elements are loaded and accounted for $(document).ready(function() { // Match to Bootstraps data-toggle for the modal // and attach an onclick event handler $('a[data-toggle="modal"]').on('click', function(e) { // From the clicked element, get the data-target arrtibute // which BS3 uses to determine the target modal var target_modal = $(e.currentTarget).data('target'); // also get the remote content's URL var remote_content = e.currentTarget.href; // Find the target modal in the DOM var modal = $(target_modal); // Find the modal's <div class="modal-body"> so we can populate it var modalBody = $(target_modal + ' .modal-body'); // Capture BS3's show.bs.modal which is fires // immediately when, you guessed it, the show instance method // for the modal is called modal.on('show.bs.modal', function () { // use your remote content URL to load the modal body modalBody.load(remote_content); }).modal(); // and show the modal // Now return a false (negating the link action) to prevent Bootstrap's JS 3.1.1 // from throwing a 'preventDefault' error due to us overriding the anchor usage. return false; }); });
We're just about there. One thing you may want to do is style the modal body with a max-height, so that long content will scroll.
In your CSS, you'll need the following:
.modal-body{ max-height: 300px; overflow-y: scroll; }
Just for refference I'll include the modal's HTML, which is a knock-off of every Bootsrap Modal Example you've ever seen:
<div id="terms" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3 id="termsLabel" class="modal-title">TERMS AND CONDITIONS</h3> </div> <div class="modal-body"> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div><!-- /.modal -->