javascript - FlightJs event propagation -


here piece of index.html:

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

i have attachd 2 flightjs components structure.

one top element:

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 broadcast message."         });     }); } 

and second lvl1a:

function lvl1a() {     this.after('initialize', function () {         console.log('[debug] lvl 1 initialized.');          this.on('broadcastevent', function (e, data) {             console.log("[debug] broadcast recived: " + data.message);         });     }); } 

my output is:

[debug] top initialized. [debug] broadcast recived: broadcast message.  [debug] lvl 1 initialized.  

why event isn't propagated children nodes? how can make happen ?

edit: figured out events propagated bottom up. there possibility change ?

the flight (jquery actually) uses standard dom event propagation schema - events bubbling child parent.

so in order receive notifications children should put event handler on document root element (<html>) or common container element <body>.

try

function lvl1a() {     this.after('initialize', function () {         console.log('[debug] lvl 1 initialized.');          $(document.body).on('broadcastevent', function (e, data) {             console.log("[debug] broadcast recived: " + data.message);         });     }); } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -