After fulfilling promises (run for 7 seconds) jQuery raises an event.

$.when(deferredActionsDone).done(function() { $(document).trigger('done'); }); 

This is how it works:

  $(document).on('done', function() { alert('deferred actions done!'); }); 

That's not how it works) Tell me where to dig, how to make it work)

  setTimeout(function() { $(document).on('done', function() { alert('deferred actions done!'); }); }, 15000); 
  • one
    in the second case, you set the handler to "done" after 15 seconds. And the done event apparently has time to come before the expiration of these 15 seconds. If there is no handler at the time of the trigger call, then this event will not be saved anywhere and will not be called later - Mike
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

2 answers 2

may try to just put a delay on the message output:

  $(document).on('done', function() { setTimeout(function() { alert('deferred actions done!'); }, 15000); }); 
     setTimeout(function() { $(document).on("done", function() { alert("deferred actions done!") }); deferredActionsDone.state() == "resolved" && $(document).trigger("done") }, 15000);