开发者

close Shadowbox from inside iframe using 2 methods

I have already searched SO for similar questions, and none of the methods worked for me.

I have a shadowbox which opens on the click of an as so:

<a href="/form/foo" rel="shadowbox;height=400;width=510">Open</a>

This works fine and my forms work best with this method (ie I can close my forms easily using

window.parent.Shadowbox.close();

Problem.. I have a page which ajax's in data, and I wanted to load a shadowbox for these "future" elements开发者_如何转开发, I thought of doing this by using the jquery delegate function.

// Open our form manually
$('body').delegate("#video-form-edit", "click", function(e){
          e.preventDefault();
          var url = $(this).attr('href'); // Our URL
          Shadowbox.open({
                content:    url,
                player:     "iframe",
                height:     400,
                width:      510
            });
});

// If I want to close ^ this ^ shadowbox, how do i do it?
// window.parent.Shadowbox.close(); // Doesnt work

The problem is that I can't close the form that is opened using the delegate method using the above "externally" loaded shadow box,

Is their a better way of doing this? How do I close a shadowbox loaded using the delegate methods.

EDIT


I keep getting error Cannot call method 'close' of undefined.
EDIT 2 Right well, since no answer, I've found I can use:

parent.window.location = parent.window.location.href;

To redirect to the parent window, Although this is not what Im looking for, it could be a solution for someone.


Duh.. I can't believe no one got it!, 18 Hours later..
I needed to Change the ID to a class
Change $('body').delegate("#video-form-edit", "click", function(e){
To ----->$('body').delegate(".video-form-edit", "click", function(e){
And also in my ahref.

Now everything works as normal in all my shadowbox, for all elements now or future.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜