1

My problem is javascript not wait for file selection dialog closing. I have just found an solution that we declare a onChange event for element. So onChange event work right, but script still run before onChange event. They a asynchronous. I think may be there is a way to check if there is any dialog opening ? Please help me, 2 day of mine :)

1 Answer 1

2

If you want to call back method after dialog is completely opened, you can use using jQuery Promise object as mentioned in this answer:

$("#dialog").dialog({
    show: {
        effect: "drop",
        direction: "up",
        duration: 1000
    },
    hide: {
        effect: "drop",
        direction: "down",
        duration: 1000
    },
    open: function () {
        $(this).parent().promise().done(function () {
            console.log("[#Dialog] Opened");
        });
    },
    close: function () {
        $(this).parent().promise().done(function () {
            console.log("[#Dialog] Closed");
        });
    }
});

Here is the usual JSFiddle Demo: http://jsfiddle.net/losnir/jcmpm/

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

1 Comment

Is it work with file Dialog, I apply the code and then the dialog not appear more :)

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.