I'm using a dynamically generated list of links to show a modal window with ajax loaded content. Bootstrap automatically caches the content and doesn't clear it on modal hide event.
我正在使用动态生成的链接列表来显示带有ajax加载内容的模态窗口。 Bootstrap会自动缓存内容,而不会在模态隐藏事件中清除它。
I need to get new content every time I click the link, how can I workaround this? I checked and there are no methods or properties to set the caching to false.
每次点击链接时我都需要获取新内容,我该如何解决这个问题?我检查过,没有方法或属性可以将缓存设置为false。
2 个解决方案
#1
4
You can use something like this:
你可以使用这样的东西:
<a href="/my/url" class="modal-toggle">test</a>
$('body').on('click', '.modal-toggle', function (event) {
event.preventDefault();
$('.modal-content').empty();
$('#myModal')
.removeData('bs.modal')
.modal({remote: $(this).attr('href') });
});
#2
1
this worked for me..
这对我有用..
$('body').on('hidden.bs.modal', '.modal', function () {
$(this).removeData('bs.modal');
});
#1
4
You can use something like this:
你可以使用这样的东西:
<a href="/my/url" class="modal-toggle">test</a>
$('body').on('click', '.modal-toggle', function (event) {
event.preventDefault();
$('.modal-content').empty();
$('#myModal')
.removeData('bs.modal')
.modal({remote: $(this).attr('href') });
});
#2
1
this worked for me..
这对我有用..
$('body').on('hidden.bs.modal', '.modal', function () {
$(this).removeData('bs.modal');
});