1

activatingイベントとを発行するプラグインを作成していますactivatedactivatedのすべてのイベント ハンドラーactivatingが実行されたときにのみ、イベントをトリガーしたいと考えています。イベントハンドラーを同期的に呼び出すことは知ってい$.trigger()ますが、問題は、イベントハンドラーに非同期コードが含まれている可能性があることです。

例:

$("test").trigger("activating");
$("test").trigger("activated");


$("test").on("activating",function()
{
     $.post("/test",{data:"test"},function()
    {
            //dom modifications here
            ////////////////
            //Here I would like to notify that the event handler is finished, like maybe async.js
    }
});

$.Deferred と Promises についていくつかの手がかりがありますが、特定の問題を解決するためにそれらを実装する方法がわかりません。

ここで誰かが私に解決策を教えてもらえますか?

ありがとう

4

0 に答える 0