Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save NathanQ/8855529 to your computer and use it in GitHub Desktop.
Save NathanQ/8855529 to your computer and use it in GitHub Desktop.
Bootstrap 3 will put a page into it's modal. Here is a way to add a section of the page to the modal using jQuery's .load().
<!-- link -->
<a href="/article.html" class="triggerModal" >
<!-- modal -->
<div id="modal" class="modal fade modal-dialog" tabindex="-1" role="dialog" aria-labelledby="yourMom" aria-hidden="true">
<div class="container">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<div class="row">
<div id="response_modal"></div>
</div>
</div>
</div>
<!-- script -->
<script>
$('.triggerModal').click(function(e) {
var responseUrl = $(this).attr('href'); // make the variable the url of the a tag
$('#response_modal').load(responseUrl + ' #idOfTheDivYouWantToLoad'); // dump the target page's id contents into the modal
$('#modal').modal(); // open the bootstrap modal
return false; // don't go to the url of the a tag
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment