1

以下は index.html の一部です。

<div id="top">
    <div id="lvl1a">
    </div>
</div>

その構造に 2 つの flightJS コンポーネントを追加しました。

最上位要素用の 1 つ:

function top() {
    this.after('initialize', function () {
        console.log('[DEBUG] Top initialized.');

        this.on('broadcastEvent', function (e, data) {
            console.log("[DEBUG] Broadcast recived: " + data.message);
        });
        this.trigger('broadcastEvent', {
            message: "This is a broadcast message."
        });
    });
}

そして lvl1a の 2 番目:

function lvl1a() {
    this.after('initialize', function () {
        console.log('[DEBUG] Lvl 1 a initialized.');

        this.on('broadcastEvent', function (e, data) {
            console.log("[DEBUG] Broadcast recived: " + data.message);
        });
    });
}

私の出力は次のとおりです。

[DEBUG] Top initialized.
[DEBUG] Broadcast recived: This is a broadcast message. 
[DEBUG] Lvl 1 a initialized. 

イベントが子ノードに伝播されないのはなぜですか? どうすればそれを実現できますか?

編集: これらのイベントはボトムアップで伝播されることがわかりました。それを変更する可能性はありますか?

4

1 に答える 1