fotorama how to work with ajax

谁说我不能喝 提交于 2019-12-07 18:45:15

问题


I got two problems by using ajax in fotorama

i) before ajax, my code is:

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

after ajax, my code is:

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

the fotorama may work or not work in this case

ii) assume the fotorama works 'successfully', when I clear data by

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

and then add the other images, the fotorama is exactly not work again. Does fotorama support ajax?


回答1:


When you clear the photos & re-add the photos you need to re-initalize the plugin again for it to work.

$("#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();


来源:https://stackoverflow.com/questions/29505626/fotorama-how-to-work-with-ajax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!