Last active
May 3, 2018 08:33
-
-
Save wkrsz/ae86d7fb59879715ae1e6dd623f743c5 to your computer and use it in GitHub Desktop.
Reload remote bootstrap modal each time it is opened
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
// http://stackoverflow.com/questions/12286332/twitter-bootstrap-remote-modal-shows-same-content-everytime | |
$(document).on('hidden.bs.modal', '.modal', function () { | |
var modalData = $(this).data('bs.modal'); | |
// Destroy modal if has remote source – don't want to destroy modals with static content. | |
if (modalData && modalData.options.remote) { | |
// Destroy component. Next time new component is created and loads fresh content | |
$(this).removeData('bs.modal'); | |
// Also clear loaded content, otherwise it would flash before new one is loaded. | |
$(this).find(".modal-content").empty(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment