I got three js Files, AppView, NavigationMenuView, and HeaderView.
I'm trying to send an event to My HeaderView when a button is pressed in NavigationMenuView. Here is what I got so far. When I click a button in navigation view an event is emitted called "settings". Then Appview catches the Event. I have a hard time trying to get this event then passed to HeaderVew. Code Is below.
Thanks
AppView Code
function AppView() {
View.apply(this, arguments);
this.menuToggle = false;
CreateHeaderView.call(this);
CreateNavigatinMenuView.call(this);
SetListeners.call(this);
}
AppView.prototype = Object.create(View.prototype);
AppView.prototype.constructor = AppView;
function CreateHeaderView() {
this.HeaderView = new HeaderView();
this.HeaderModifier = new StateModifier();
this.add(this.HeaderModifier).add(this.HeaderView);
}
function CreateNavigatinMenuView() {
this.NavigationView = new NavigationMenuView();
this.NavigationViewModifier = new StateModifier();
this.NavigationViewModifier.setTransform(
Transform.translate(-dimensions[0], 0, 0), {}
);
this.add(this.NavigationViewModifier).add(this.NavigationView);
}
function SetListeners() {
this.NavigationView.on('settings', function () {
//HERE IS WHERE I WHOULD EMIT TO HEADER VIEW
}.bind(this.HeaderView));
}
module.exports = AppView;
});
AppView
function SetListeners() {
this.settingsButton.on('click', function () {
this._eventOutput.emit('settings');
}.bind(this));
}
HeaderView
context.on('settings', function () {
alert("Test");
}.bind(this));