Skip to content

Instantly share code, notes, and snippets.

@AlexanderLindsay
Created April 24, 2016 03:04
Show Gist options
  • Save AlexanderLindsay/f0944a68d187e409480d79b43ebc9430 to your computer and use it in GitHub Desktop.
Save AlexanderLindsay/f0944a68d187e409480d79b43ebc9430 to your computer and use it in GitHub Desktop.
javascript to load a bootstrap modal content from an anchor tag
// boostrap 4 load modal example from docs
$('#modal-container').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget); // Button that triggered the modal
var url = button.attr("href");
var modal = $(this);
// note that this will replace the content of modal-content ever time the modal is opened
modal.find('.modal-content').load(url);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment