Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@navdeepsingh
Last active July 28, 2016 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save navdeepsingh/de4718a074b812637330f668d2a73b7e to your computer and use it in GitHub Desktop.
Save navdeepsingh/de4718a074b812637330f668d2a73b7e to your computer and use it in GitHub Desktop.
Load Dynamic (AJAX) modal in Bootstrap 3, remove from DOM after timeout
$('[data-toggle="modal"]').click(function () {
var url = $(this).attr('href');
$.get(url, function (data) {
var modal = $('<div id="clue-modal" class="modal fade" tabindex="-1" role="dialog"><div class="modal-dialog"><div class="modal-content">' + data + '</div></div></div>').modal();
modal.on("hidden.bs.modal", function () {
$(this).remove();
});
setTimeout(function(){
modal.modal('hide');
},5000);
});
});
// Ref: https://getbootstrap.com/javascript/#modals-events
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment