开发者

Redirect parent window from within Jquery modal UI

I load a Jquery Modal UI with the following code:

// Dialog   
            $('#avatar-manager').click(function () {
                $dialog.dialog('open');
                return false;
            });

            var $dialog = $('<div></div>')
                .dialog({
                    autoOpen: false,
                    resizeable: false,
                    modal: true,
                    title: 'Change your avatar...',
                    position: 'top',
                    width: 600,
                    open: function () {
                        $(this).load('/components/avatar/avatar.开发者_C百科aspx?id=<%=Helpers.CurrentUserId(Session["SessionHash"].ToString())%>&type=user');
                    }
                });
            $dialog.parent().appendTo(jQuery("form:first"));

All works well. The avatar.aspx page has the code on an a to complete the process:

$('#go').live('click', function () {
                $('#croppanel').hide();
                $('#loadingpanel').show();
                $.ajax({
                    type: "POST",
                    url: "http://<%=Atomic.UI.Helpers.CurrentServer()%>/AtomicService/Assets.asmx/CreateAvatar",
                    data: "{'avatarPath':'" + file_path + "','type':'user', 'w':'" + $('#<%=w.ClientID%>').val() + "','h':'" + $('#<%=h.ClientID%>').val() + "','x':'" + $('#<%=x.ClientID%>').val() + "','y':'" + $('#<%=y.ClientID%>').val() + "'}",
                    contentType: "application/json",
                    dataType: "json",
                    success: function (msg) {
                        if (msg["d"].length > 0) {
                            //done
                            //$dialog.dialog('close');
                            var cachekiller = Math.floor(Math.random() * 1000);
                            >>>> 
                        }
                    },
                    error: function (msg) {
                        alert("Unfortunately, we can't upload that image now. Why not try again?");
                        $('#loadingpanel').hide();
                        $('#croppanel').show();
                    }
                });

I would like to redirect or close the modal where the >>>>'s are. How can I do this? I know $(this).dialog can't access the modal because of context, but I'm at a loss how to close from within the window. Remembering this a completely seperate page to where the dialog instantiation is done.

Help, suggestions and questions appreciated :)


Although my question perhaps didn't read that a really simple solution was required, it turned out that all I needed was:

setTimeout(window.location.reload(true), 3000);

Worked a treat :)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜