简体   繁体   English

使用Shadowbox jQuery在div中加载PHP页面时出现问题

[英]Problem on load a PHP page in a div with Shadowbox jQuery

I have a php page call it page.php . 我有一个php页面,称为page.php。 In this page I am using the shadowbox effect for opening a new php page (subpage.php) on it. 在此页面中,我正在使用shadowbox效果在其上打开一个新的php页面(subpage.php)。 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
    });
  });

});

And then in the html code I am using : 然后在html代码中,我正在使用:

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

The shadowbox works ok and I can see the content of subpage.php in it. Shadowbox可以正常运行,我可以在其中看到subpage.php的内容。 The problem is that when I am using jQuery code like click(), in the subapage.php it doesn't work. 问题是,当我使用诸如click()之类的jQuery代码时,在subapage.php中它不起作用。 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. 可能在加载subpage.php之后,此操作不起作用,类似这样。

Does anyone have an idea of what could be wrong? 有谁知道可能出什么问题?

Thanks in advance 提前致谢

That's because when you do content:$("#hiddenDiv").html() you get the contents of the preloaded subpage into a different container. 这是因为当您执行content:$("#hiddenDiv").html()预加载子页面的内容放入另一个容器中。 So, after that the elements in this new container aren't bound. 因此,此后,此新容器中的元素将不再绑定。

You can automatically rebind them replacing .click(function() {...}) for .live('click', function() {...}) 您可以自动重新绑定他们更换.click(function() {...}).live('click', function() {...})

thats because the click in subpage is not binded. 多数民众赞成,因为在子页面中的点击未绑定。 a simple workaround could be to bind the click in the subpage.php file. 一个简单的解决方法是将点击绑定到subpage.php文件中。

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

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