javascript - fotorama 如何使用 ajax

标签 javascript jquery ajax fotorama

我在 fotorama 中使用 ajax 遇到了两个问题

i) 在ajax之前,我的代码是:

<div id="AjaxPhoto" class="fotorama" data-nav="thumbs" data-ratio="4/3"></div>

在ajax之后,我的代码是:

<div id="AjaxPhoto" class="fotorama" data-nav="thumbs" data-ratio="4/3">
  <img src="1.jpg" />
  <img src="2.jpg" />
</div>

在这种情况下,fotorama 可能有效,也可能无效

ii) 假设 fotorama 工作“成功”,当我清除数据时

$("#AjaxPhoto").empty();
$(".fotorama--hidden").remove();

然后再添加其他图片,fotorama又不行了。 fotorama是否支持ajax?

最佳答案

当您清除照片并重新添加照片时,您需要重新初始化插件才能正常工作。

$("#AjaxPhoto").empty();
$(".fotorama--hidden").remove();
// Load the new set of Photos here
// after that the below statement will re-initialize the fotorama gallery plugin
$('.fotorama').fotorama();

关于javascript - fotorama 如何使用 ajax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29505626/

相关文章:

javascript - bootstrap 4.1.3 dropdown+proper+可滚动菜单=闪烁

jQuery select- 如何更改 css 样式选择?

javascript - Highcharts - 线系列中的自定义数据标签,在窗口调整大小时消失

javascript - 带有 Bootstrap 主题的 Mottie 虚拟键盘

javascript - JQuery - 如何在父元素之后插入元素?

javascript - 将实时数据传输到网页

javascript - 使用 javascript 或 ajax 弹出窗口显示所选选项

jquery - onclick jquery 菜单在 ajax 之后不起作用

Javascript 下一个/上一个脚本

javascript - 使用简单的 jQuery 选择器