通过get在fancybox中的动态内容 [英] Dynamic content inside fancybox via get

查看:103
本文介绍了通过get在fancybox中的动态内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个fancybox实例同时工作,如下所示:

I have multiple instances of fancybox working at the same time like this:

<a class="grupito" href="?id=1#various1">Group 1</a>
<a class="grupito" href="?id=2#various1">Group 2</a>
<a class="grupito" href="?id=3#various1">Group 3</a>

显示以下div:

<div style="display: none;">
   <div id="various1">
       //Select that shows the people from the group here depending on the id 
       //of the link with a $_GET['id'] variable (from database)
   </div>
</div>

通过此呼叫:

$("a.grupito").fancybox({
            'titlePosition'     : 'inside',
            'transitionIn'      : 'none',
            'transitionOut'     : 'none'
        });
});

这对我不起作用. Fancybox说:无法加载所请求的内容. 请稍候再试.".如果我摆脱了href的?id = 1部分,它将显示出来,但没有我需要的内容.这是否可以通过fancybox尝试?

This doesn't work for me. Fancybox says "The requested content cannot be loaded. Please try again later.". If I get rid of the ?id=1 part of the href it will show up but it won't have the content that I need. Is this that I'm trying even possible with fancybox?

实际上,用firebug检查它,我看到我收到404错误.任何人都可以向我指出正确的方向,看看我如何实现这一目标?

In fact, checking it with firebug I see I'm getting a 404 error. Anyone can point me out in the right direction to see how I can achieve this?

推荐答案

如果我正确理解了您的问题,我认为您可能需要重新考虑您的方法.我不确定您要通过向锚添加?id = 1来实现什么. Fancybox显示页面上已加载的内容.呈现HTML页面并将其发送到浏览器后,PHP不会在客户端发生的事情中发挥作用.

If I understand your questions properly I think you may need to rethink your approach. I'm not sure what you are trying to achieve by adding ?id=1 to your anchor. Fancybox shows content that is already loaded on the page. Once the HTML page has been rendered and sent to the browser, PHP plays no role in what happens on the client side.

页面加载时,您需要呈现每个框的所有内容,然后在内部链接中引用它们,如下所示. Fancybox仅处理已加载到页面上的内容,因此您需要在每个盒子的初始呈现期间弄清楚它们的内容.

You need to render all the content for each of the boxes when the page loads and then reference them within your internal links as posted below. Fancybox only deals with content that has been loaded on to the page, so you need to figure out the content of each box during it's initial rendering.

<a class="grupito" href="#various1">Group 1</a>
<a class="grupito" href="#various2">Group 2</a>
<a class="grupito" href="#various3">Group 3</a>

<div style="display: none;">
   <div id="various1">
       //The content from group 1
   </div>
   <div id="various2">
       //The content from group 2
   </div>
   <div id="various3">
       //The content from group 3
   </div>
</div>

这篇关于通过get在fancybox中的动态内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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