Skip to content

Instantly share code, notes, and snippets.

@kdarty
Created September 13, 2016 15:51
Show Gist options
  • Save kdarty/26ae8788c9bf2d1891aaf13d53b63cdc to your computer and use it in GitHub Desktop.
Save kdarty/26ae8788c9bf2d1891aaf13d53b63cdc to your computer and use it in GitHub Desktop.
Here's a good example of how to run code as a Bootstrap Modal Loads. This is good for when you are remotely loading content into a Bootstrap Modal and want to execute some code against the newly loaded DOM. Simply add a callback function to your jQuery 'load' method that will fire once the content is loaded.
// Source Discussion: https://github.com/twbs/bootstrap/issues/5169
$('#do-modal').click(function(e) {
e.stopPropagation();
$('#foo .modal-body').load(this.href, function(response, status, xhr) {
/* do something cool */
$('#foo').modal();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment