在AJAX加载的页面使用的fancybox加载、页面、AJAX、fancybox

2023-09-10 13:35:03 作者:多碍你

我搜索此组和周围一派,但仍然在答案没有运气 我也看到一些有我的问题,但线程没有帮助,所以在这里我

I searched in this group and googled around, but still no luck in answers I see also that some have my problem, but the threads didn't help, so here I am

现在的问题是容易的,以帮助你,我已经打包的.zip与 文件可以测试

The question is easy, and to help you I've packed a .zip with the files you can test

http://www.ivanhalen.com/fancyproblem.zip

在我有一些linkes主网页(的index.php) 点击它们加载一个片段througn AJAX(page.php) 在片段中有一个或多个链接,点击它们应该 打开iframed的fancybox(fb.php) I have a main page with some linkes (index.php) Clicking on them loads a snippet througn AJAX (page.php) In the snippet there is one or more links, clicking on them should open an iframed fancybox (fb.php)

那么,刚刚的fancybox不会除了第一个打开的连接工作, 然后,我不断收到一个T没有定义的错误在Firefox中,这点 我无处 我想真正的一切,我能想象,但仍没有运气...

Well, the fancybox just won't work, except for the first opened link Then I keep getting a "t is not defined" error in Firefox, that points me nowhere I tried really everything I could imagine, but still no luck...

请,你能帮助我吗? 非常感谢

Please, can you help me? Thanks a lot

推荐答案

不要把脚本的fancybox()您在Ajax响应的内容链接。相反,你需要做的是移动的fancybox()调入完整的()负载的功能的回调,像这样:

Don't put the script to fancybox() your links in content of the ajax response. Instead, what you want to do is move the fancybox() call into the complete() callback of the load function, like so:

$(document).ready(function(){
    $('#links a').live('click', function(e){
        e.preventDefault();
        var url = $(this).attr('href');
        $('#content').load(url, function(data, stat, req){
            $("a#popup").fancybox();
        });
    })
});