bootstrap 3 动态模式 - ajax 内容缓存问题 [英] bootstrap 3 dynamic modal - ajax content caching issue

查看:18
本文介绍了bootstrap 3 动态模式 - ajax 内容缓存问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个动态引导模式,根据我发送到同一域中的外部页面的 ID,结果需要在引导模式中找到我.系统在您第一次加载页面时工作,但如果我点击另一个链接打开不同的模式,我应该看到不同的结果,但它只显示第一个结果......这基本上是缓存结果.

这是我所做的.我也试过发送时间戳等,但还是一样.

开放模态

这是我在同一页面上的模态

<div class="modalfade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

<!--/.modal -->

那么如何在不缓存结果的情况下加载远程内容?

解决方案

每次显示模态时,使用以下 JavaScript 清除缓存:

$('#myModal').on('shown.bs.modal', function () {$(this).removeData('bs.modal');});

还值得注意的是,远程模式在 Bootstrap v3.2.1 中已被弃用,并且将在 Bootstrap v4 中完全删除.

I need a dynamic bootstrap modal, depending on the id I sent to an exterior page in the same domain the result needs to come to me in a bootstrap modal. The system works when you first load the page but if I click on another link to open different modal I should see different result but it only shows the first result...which is basically caching the result.

Here is what I have done. I also tried sending timestamp etc but it is still the same.

<a href='modal_window.php?mpage_id=$mpage_id' mpage_id='$mpage_id' data-toggle='modal' data-target='#myModal'> open modal </a>

This is my modal on the same page

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-  labelledby="myModalLabel" aria-hidden="true">
</div>
<!-- /.modal -->

So how can I load remote content without caching the result?

解决方案

Use the following JavaScript to purge the cache every time the modal is displayed:

$('#myModal').on('shown.bs.modal', function () {
    $(this).removeData('bs.modal');
});

It's also worth noting that remote modals are being deprecated in Bootstrap v3.2.1 and will be removed entirely in Bootstrap v4.

这篇关于bootstrap 3 动态模式 - ajax 内容缓存问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆