I am using Twitter bootstrap, I have specified a modal
<
-
For bootstrap 3 you should use:
$('body').on('hidden.bs.modal', '.modal', function () {
$(this).removeData('bs.modal');
});
讨论(0)
-
I've added something like this, because the older content is shown until the new one appears, with .html('') inside the .modal-content will clear the HTML inside, hope it helps
$('#myModal').on('hidden.bs.modal', function () {
$('#myModal').removeData('bs.modal');
$('#myModal').find('.modal-content').html('');
});
讨论(0)
-
If a remote URL is provided, content will be loaded one time via jQuery's load method and injected into the .modal-content div. If you're using the data-api, you may alternatively use the href attribute to specify the remote source. An example of this is shown below
$.ajaxSetup ({
// Disable caching of AJAX responses
cache: false
});
讨论(0)
-
I wrote a simple snippet handling the refreshing of the modal.
Basically it stores the clicked link in the modal's data and check if it's the same link that has been clicked, removing or not the modal data.
var handleModal = function()
{
$('.triggeringLink').click(function(event) {
var $logsModal = $('#logsModal');
var $triggeringLink = $logsModal.data('triggeringLink');
event.preventDefault();
if ($logsModal.data('modal') != undefined
&& $triggeringLink != undefined
&& !$triggeringLink.is($(this))
) {
$logsModal.removeData('modal');
}
$logsModal.data('triggeringLink', $(this));
$logsModal.modal({ remote: $(this).attr('href') });
$logsModal.modal('show');
});
};
讨论(0)