我知道在 BS 3 中,调用模态对话框时,如果将外部页面加载到模态中,则需要插入以下 js 以在隐藏模态数据时将其删除:
$('body').on('hidden.bs.modal', '#ModalID', function () {
$(this).removeData('bs.modal');
});
我使用这个加载模式:
$('.select-modal').click(function(ev) {
var url = $(this).attr('href');
$('#ModalID').modal({
show: true,
remote: url
});
return false;
它加载了一个带有包含图像的上下文的 TemplateView:
class ImageSelectView(LoginRequiredMixin, TemplateView):
template_name = 'imageviewer/image_modal.html'
def get_context_data(self, **kwargs):
context = super(ImageSelectView, self).get_context_data(**kwargs)
context['images'] = Image.objects.for_user(self.request.user).order_by('-created')
return context
它在我的开发机器上工作正常,添加到 Image 的新项目出现。在生产服务器上,更改不会反映在模式中。我尝试过清除 Memcache、清除浏览器缓存、尝试不同的加载 url 的方式等。