使用Shadowbox jQuery在div中加载PHP页面时出现问题 [英] Problem on load a PHP page in a div with Shadowbox jQuery

查看:78
本文介绍了使用Shadowbox jQuery在div中加载PHP页面时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个php页面,称为page.php.在此页面中,我使用shadowbox效果在其上打开一个新的php页面(subpage.php).所以我有类似的东西:

I have a php page call it page.php . In this page I am using the shadowbox effect for opening a new php page (subpage.php) on it. So I have something like:

$(document).ready(function() { 
  Shadowbox.init();

  $("#configure").click(function(){
    Shadowbox.open({
      content:    $("#hiddenDiv").html(),
      player:     "html",
      title:      "Hello",
      height:     600,
      width:      840
    });
  });

});

然后在我使用的html代码中:

And then in the html code I am using :

<div id="hiddenDiv" style="display:none;">
   <?php include 'subpage.php'; ?>
</div>

shadowbox正常运行,我可以在其中看到subpage.php的内容.问题是,当我使用诸如click()之类的jQuery代码时,在subapage.php中它不起作用.如果我很了解,就好像负载有问题.可能在加载subpage.php之后,此操作不起作用,类似这样.

The shadowbox works ok and I can see the content of subpage.php in it. The problem is that when I am using jQuery code like click(), in the subapage.php it doesn't work. Is like something is wrong with the load if I understood well. Probably the subpage.php is loaded after and this thing doesn't work, something like this.

有人知道什么地方可能出问题吗?

Does anyone have an idea of what could be wrong?

预先感谢

推荐答案

这是因为当您执行content:$("#hiddenDiv").html()时,会将预加载的子页面的内容放入另一个容器中.因此,此后,此新容器中的元素将不再绑定.

That's because when you do content:$("#hiddenDiv").html() you get the contents of the preloaded subpage into a different container. So, after that the elements in this new container aren't bound.

您可以自动重新绑定它们,将.click(function() {...})替换为.live('click', function() {...})

You can automatically rebind them replacing .click(function() {...}) for .live('click', function() {...})

这篇关于使用Shadowbox jQuery在div中加载PHP页面时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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