开发者

Can I load the content before Shadowbox opens with jQuery?

开发者 https://www.devze.com 2023-03-03 23:00 出处:网络
I did a post before here regarding a problem I had with the shadowbox. In summary, I want to open a subpage.php inside a shadowbox called in page.php.

I did a post before here regarding a problem I had with the shadowbox. In summary, I want to open a subpage.php inside a shadowbox called in page.php.

The problem is that the content of the shadowbox is l开发者_JS百科oaded after the shadowbox.open so I cannot play with some jQuery events in the subpage.php. I noticed for example that if I open once the shadowbox and click a button that should show another box, this thing is not working until I close the shadowbox and open it again.

I am not sure this is the solution, but does anyone know a way to load the shadowbox content before opening it?

Thanks in advance


You could try to use JQuery's .load function to pull the content into the container, before you call the shadowbox plugin ?

http://api.jquery.com/load/


If i interpreted your question correctly. You want to open shadowbox when your page is loaded.

If that is the problem then you can use ajax call or load.

Load:

jQuery("#div").load(url,function(){open_shadowbox_function()});

your open_shadowbox_function can open a shadowbox for that div.

Ajax:

jQuery.ajax({
   type:"POST/GET",
   url: url,
   success:function(data){
        jQuery("#div").html(data);
        open_shadowbox_function();
   }

});

Hope that helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消