How can i pass events through module hierarchy? I have the main app.js, there i load the module welcome.js (with require("welcome") ) as a window and inside welcome i load modules home.js (the view containing the login and register buttons) and login.js. The problem is i don't know what is the right method to notify app.js and welcome.js about events in login.js. For example when the user wants to go back, inside the welcome i have to hide login and show home, when the user logs in i have to destroy the welcome and load main.js inside app.js. Should i create a callback in app.js and pass it to welcome which passes it to login, create a global event listener in app and fire an event in login, or is there a better way i haven't found yet?
↧