Created
April 24, 2016 02:57
-
-
Save AlexanderLindsay/f025550030d69bca903c780bb789ba78 to your computer and use it in GitHub Desktop.
javascript to clear a bootstrap modal on close
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
$(function () { | |
// when the modal is closed | |
$('#modal-container').on('hidden.bs.modal', function () { | |
// remove the bs.modal data attribute from it | |
$(this).removeData('bs.modal'); | |
// and empty the modal-content element | |
$('#modal-container .modal-content').empty(); | |
}); | |
}); |
after $('#modal-container .modal-content').empty(); modal does not shows up.
kindly consider using the id or class of the element you want cleared or removed rather than the whole modal-content and modal-container classes.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modal is not appearing when it is reopened! :(