Problem on load a PHP page in a div with Shadowbox jQuery

这一生的挚爱 提交于 2019-12-13 03:40:53

问题


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
    });
  });

});

And then in the html code I am using :

<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. 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?

Thanks in advance


回答1:


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.

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




回答2:


thats because the click in subpage is not binded. a simple workaround could be to bind the click in the subpage.php file.



来源:https://stackoverflow.com/questions/5908685/problem-on-load-a-php-page-in-a-div-with-shadowbox-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!