I have a standard view component showing a few buttons. I want to enable/disable these buttons depending on different scenarious.
One scenario is the ‘onLoad’ of a component.
Considering I have 2 buttons, button1 and button2, and a variable a=false,
I’d want something like:
{
id: component1,
on: onLoad: function() {
if (a) { $$(“button1”).disable(); }
}
rows: [ { // buttons go here }]
}
But there is no onLoad or onReady for a (basic) component as far as I can tell from the docs / forum. So… how do I achieve what I want?
Hello @Robbert ,
There is no specific events which would exactly fit this description.
The initialization is the synchronous process in Webix UI library, so basically, you can call the needed logic after UI init:
// instead of onDocumentReady
webix.ready(()=>{
webix.ui({ ... });
myMethod(); // disable unnecessary controls after UI is ready
})
Considering the aplicable events:
-
Containers (layout, form, toolbar) has no events related to their init.
-
Data components (such as datatable, tree, and so on) have two similar handlers that could fit the use-case (data-related): ready and waitData.
-
All form controls (inputs, buttons, etc), template, and data components feature onAfterRender event, but please be aware that it will be triggered each time the view is updated, e.g. resize, setting new value or data operations (update, sorting, selection - any action that results in repainting).
To call it only once, you can use the corresponding helper.
Finally, if you plan to use some framework with Webix, than it is possible to use the related events from there.
As an example, the order of view-related events in Webix Jet allows to track the state of any app module.