2

I have a JQuery UI modal:

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

            $('#dialog').dialog({
                autoOpen: false,
                resizeable: false,
                modal: true,
                position: 'center',
                width: 600,
                open: function () {
                    $(this).load('/a/path/to/my/page.aspx');
                }
            });

And it works wonderfully. page.aspx (example name) contains my upload functionality for images. What I'd like to do is on completion of the upload, to redirect the user to another modal:

uploader.bind('FileUploaded', function (up, file, obj) {
            alert("I've done uploading stuff...");
            //redirect to another modal here...
        });

I know I can't use windows.location and the like, because that will change the main parent window, so I'm not sure how - or even if I can - do this...

1 Answer 1

1

Have you tried simply close the current dialog and open another one?

    $('#dialog2').dialog({
        autoOpen: false;
        modal: true
    });

    uploader.bind('FileUploaded', function (up, file, obj) {
        $('#dialog').dialog('close');
        $('#dialog2').html('Upload finished').dialog('open');
    });

Edit:

You can refer to the dialog several ways depending on how you want to do it. If you want absolute reference, just use $('#dialog'); if you want a relative reference, you could make use of $.proxy(), apply() or call() to pass in the dialog as the substituting context, so you can use $(this) to refer to the dialog.

Sign up to request clarification or add additional context in comments.

4 Comments

Hi William, thanks for the answer. Unfortunately, it isn't that simple. The dialog is initialised from a 'parent' page and calls the 'component' page which contains the uploader code. If I reference the 'parent' page objects (such as dialog), it can't find it - because the dialog can't seem to see itself. Placing the uploader.bind functions within the parent is also not an option because I wish to keep it as an upload widget type thing without dependencies on the parent page.
I'm not sure I got you. I assume by "parent page", you meant the actual HTML DOM, and by "component page" you meant the uploader dialog. And you want some way to link the uploader dialog back to the "parent page". Is it right?
Yep, that's correct. The dialog can't 'see itself', so I can't go window.parent.$('#dialog') for instance. $(this) doesn't seem to work either...
Thanks for the answer William ;) It was the call() functionality that I was missing. With thye context being passed in, I can control the dialog from within the dialog... :) +1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.