fotorama如何使用ajax

gam*_*mer 2 javascript ajax jquery fotorama

我在fotorama中使用ajax有两个问题

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

<div id="AjaxPhoto" class="fotorama" data-nav="thumbs" data-ratio="4/3"></div>
Run Code Online (Sandbox Code Playgroud)

在ajax之后,我的代码是:

<div id="AjaxPhoto" class="fotorama" data-nav="thumbs" data-ratio="4/3">
  <img src="1.jpg" />
  <img src="2.jpg" />
</div>
Run Code Online (Sandbox Code Playgroud)

在这种情况下,fotorama可能起作用或不起作用

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

$("#AjaxPhoto").empty();
$(".fotorama--hidden").remove();
Run Code Online (Sandbox Code Playgroud)

然后添加其他图像,fotorama完全不再工作.fotorama支持ajax吗?

Roh*_*tra 6

当您清除照片并重新添加照片时,您需要再次重新插入插件以使其正常工作.

$("#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();
Run Code Online (Sandbox Code Playgroud)