AJAX更新DOM后如何重新初始化(调用)FancyBox? [英] How to reinitialize (recall) FancyBox after AJAX updated DOM?

查看:84
本文介绍了AJAX更新DOM后如何重新初始化(调用)FancyBox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将widgetkit插件(Joomla CMS)用于灯箱.由于widgetkit使用fancybox来显示灯箱,因此我在此处发布了问题.

I'm using widgetkit plugin (Joomla CMS), for lightbox. Since widgetkit uses fancybox to display lightbox im posting a question here.

当我不使用AJAX技术更新Joomla网站的内容时,FancyBox效果很好.当我启用AJAX并使用ajax技术刷新或移至另一页面时,灯箱效果消失了-图像本身在新窗口中打开.我认为这是因为AJAX更新了DOM,而FancyBox无法识别这一点.我在AJAX代码插件中确实有一个区域,我可以在其中编写某些JavaScript代码,该代码将在AJAX完全加载网站后由AJAX执行. 我只是想知道应该在其中键入什么,以将FancyBox初始化为刚生成的AJAX的新DOM.

FancyBox works great when i'm not using AJAX technology to update the content of the Joomla website. When i enable AJAX, and refresh or move to another page using ajax technology lightbox effect is gone - the image itself opens in a new window. I think this is because AJAX updates the DOM and FancyBox doesn't recognize that. I do have in the plugin of AJAX code an area, where i can write certain JavaScript code, that will AJAX execute after the website is fully loaded by AJAX. I'm just wondering what should i type in there, to initialize the FancyBox to the new DOM, that AJAX just generated.

对于mootools灯箱(如果有的话),我可以简单地编写以下行:window.fireEvent('domready');

For mootools lightbox (if i had it) i could simply write this line: window.fireEvent('domready');

我不知道如何为jQuery FancyBox做到这一点.

I don't know how to do that for jQuery FancyBox.

我还在这里发布了相同的问题(如果有人需要更多信息): http://skrij.me/Qv56

I also posted the same question here (if anyone needs more information): http://skrij.me/Qv56

推荐答案

您每次对DOM进行更改时都调用fancybox(例如$(".fancybox").fancybox();),或者使用使用实时"附加点击处理程序的版本2

You either call fancybox (e.g., $(".fancybox").fancybox();) each time you make changes to the DOM or use version 2 that uses "live" to attach click handler

这篇关于AJAX更新DOM后如何重新初始化(调用)FancyBox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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