简体   繁体   English

Facebox内容被多次添加

[英]Facebox content is added multiple times

In the Facebox JavaScript plug-in, my content is adding multiple times. 在Facebox JavaScript插件中,我的内容正在多次添加。

Here is my code for initializing the Facebox code 这是我用于初始化Facebox代码的代码

$(document).ready(function(){
    $('a[rel*=facebox]').facebox();
}); 

Any idea why the content is generating multiple times? 知道为什么内容多次生成吗?

here we go 开始了

$(document).bind('beforeReveal.facebox', function() {
  $("#facebox .content").empty();
});

My Problem is same, but after looking closely in debugger i found that facebox previous request can not stops and it get continues, like one click one request sending, 2nd click two request sending although first and second request Gives OK message, it means action performed successfully. 我的问题是相同的,但是在调试器中仔细查看后,我发现facebox先前的请求无法停止并且继续执行,例如单击一次发送一个请求,第二次单击两次发送请求,尽管第一个和第二个请求给出了OK消息,这表示已执行操作成功。 However for every click previous request also get call like adding each request to a stack and and stack doesn't flush. 但是,对于每次单击,先前的请求也会得到调用,例如将每个请求添加到堆栈中,并且堆栈不会刷新。

It's making facebox pop-up slower in log run (ie. When i am clicking multiple time. It's response time delayed.) 这使得在日志运行中Facebox弹出窗口变慢(即,当我单击多个时间时。响应时间延迟了。)

I know this is old however I have just resolved the exact same issue. 我知道这很旧,但是我刚刚解决了完全相同的问题。 Mine kept adding an additional GET call with each Facebox request so I resolved it by removing: 我一直在每个Facebox请求中添加一个额外的GET调用,因此我通过删除以下方法解决了该问题:

rel="facebox"

from the affected elements, added an ID to each one and called Facebox with: 从受影响的元素中,为每个元素添加一个ID,并使用以下名称调用Facebox:

$("#elementID").click(function(){
    $.facebox({ ajax: "my-facebox-file.html" });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM