Webix Jet - Events triggered multiple times

Hi,

im making an app based on the webix jet demo app.
Im using the global event bus to communicate between views.
But now i noticed that my events are called multiple times. For example if i visit the view url 3 times, then at the last visit the events will be triggered 3 times.

Here are some parts of the code in this subview.
Basically i have a richselect that should trigger the event defined in $oninit. Like sad the problem is that it triggers it multiple times.
Any idea why this could happen?

var controls = [
		{view:"richselect", id:"order_filter", value: "all", maxWidth: 400, minWidth: 250, vertical: true, labelWidth: 100, options:[
			{id:"7", value:"7 days back"},
		],  label:"Change time", on:{
				onChange:function(){
					app.trigger("onChangeDaysBack");
				}
			}
		}
	];

.
.
.

return {
		$ui: layout,
		$oninit: function(view, $scope){
			
			
			app.attachEvent("onChangeDaysBack" ,function(){
				debugger;
			}
		}
	}
				

Hi,

Actually, the event is triggered once, but the new event handler is added each time the $oninit is called - and it is an expected behaviour.

To avoid this you can either detach the event handler within the $ondestroy (not the best practice) or attach the handler to the $scope rather than the whole app:

$oninit: function(view, $scope){
     $scope.on(app, "onChangeDaysBack" , function(){
          debugger;
     }
}

The following notation also attaches the handler to the $scope:

$oninit:function(){...},
$on:{
   "onChangeDaysBack":function(){
       debugger;
    }
}

When attached to $scope, event handlers are automatically detached when the view is destroyed.

We have updated the related documentation as well as the sample in the jet-demos repo.