Skip to content

Instantly share code, notes, and snippets.

@wkrsz
Last active May 3, 2018 08:33
Show Gist options
  • Save wkrsz/ae86d7fb59879715ae1e6dd623f743c5 to your computer and use it in GitHub Desktop.
Save wkrsz/ae86d7fb59879715ae1e6dd623f743c5 to your computer and use it in GitHub Desktop.
Reload remote bootstrap modal each time it is opened
// 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