Expanded version of accepted answer by @merv. It also checks if modal being hidden is loaded from remote source and clears old content to prevent it from flashing.
$(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();
}
});
https://gist.github.com/WojtekKruszewski/ae86d7fb59879715ae1e6dd623f743c5