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 :)

Chien Tran
  • 133
  • 2
  • 11

1 Answers1

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/

Cœur
  • 37,241
  • 25
  • 195
  • 267
Altis S.
  • 21
  • 2