-
-
Save mfd/c12ee9f6e0a65a0f6a988f561a1e75af to your computer and use it in GitHub Desktop.
Load Dynamic (AJAX) modal in Bootstrap 3, remove from DOM after timeout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('[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