Inner Events and Error Handling
You can use a number of inner events for some additional actions if the plugins aren't enough or for error handling and debugging.
You can create custom app-wide events with the callEvent method:
// views/top.js
import {JetView} from "webix-jet";
export default class TopView extends JetView {
config(){
return {
view:"icon",
icon:"wxi-calendar",
click: () => this.app.callEvent("app:action:calendar", [])
};
}
}
// views/top.js
import {JetView} from "webix-jet";
export default class TopView extends JetView {
...
init(){
this.on(this.app, "app:action:remove", id =>
this.RemoveOption(id)
);
}
RemoveOption(id){
// remove options
}
}
This way of attaching an event handler is convenient, because it automatically detaches the event handler when the view that called it is destroyed. This helps to avoid memory leaks that may happen, especially in older browsers.
// myapp.js
...
// "app:guard" is a default app event
app.attachEvent("app:guard", function(url, view, nav){
if (url.indexOf("/blocked") !== -1){
nav.redirect = "/top/allowed";
}
});

Redirecting users in apps with Webix Jet
If you include webix.js (not webix.min.js) and set the debug property in your app config, error messages will be logged in the console. Besides logging errors, this will enable the debugger.
// myapp.js
import {JetApp} from "webix-jet";
const app = new JetApp({
debug: true // console.log and debugger on error
});
You can handle error events to avoid a disaster in a production app. For example, if there is something wrong with the app URL that the user tries to access, redirect the app to something valid:
// myapp.js
...
app.attachEvent("app:error:resolve", function() {
webix.delay(() => app.show("/top"));
});
All JetApp error events:
- app:error:render - the event that is triggered on errors during view rendering, mostly Webix UI related. It means that some view UI config has been written incorrectly.
- app:error:initview - the event that is triggered when there is something wrong with view rendering, mostly Webix Jet related. It means that Jet, while rendering Webix UIs, was unable to render the app UI correctly.
The last two events are mostly helpful for the development stage.
Last modified 1yr ago