common rendered event for all components ?

Hello

Is there a single event so i can detect when a layout has been rendered (or showed) ?

In a lazy/dynamic GUI, i need to initialize some stuffs juste after rendering (first time).

So, i already use webix.once + onAfterRender/onViewShow for some widgets, but i’m really frustrated that i don’t have a uniq and same event, common to all compoments (including layout), to detected when rendering has been done.

Perhaps it already exists, perhaps not.

If not, is there a way to patch webix on my side to add onAfterRender for layouts ?

Really tired to use onAfterRender from a subcomponent to trigger something on the main compoment. Do you see ?

Perhaps i miss something so, i’m posting here. Thank you.

Btw, why onViewShow is not triggered here ?

https://snippet.webix.com/0fzmuz4c

https://docs.webix.com/api__refs__eventsystem.html

Look at the last comment (most recent), this is exactly that.

The workaround is not ideal for me.

I’d really like to patch webix to have onBeforeRender or onAfterRender for layouts too. Any hints/help welcome.

A single event, same for every components, telling me that it has been rendered.

Hello @franck34 ,

Is there a single event so i can detect when a layout has been rendered (or showed) ?
You can wrap your code in webix.ready(). It ensures the correct initialization order of the appropriate handlers. 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({ ... });
   customMethod();     // call after UI is ready
})

To quote from our documentation:
This method is an alternative to the onDocumentReady event and can be used instead of the onload() method. The event handler code is called just after the page has been completely parsed, protecting you from potential errors. Placing your code in webix.ready() is optional but we strongly encourage using it.

Btw, why onViewShow is not triggered here ?

Please note that containers has no such event. This is a data components (such as datatable, tree, and so on) event. But please be advised, the onViewShow fires when hidden view is shown:
https://snippet.webix.com/ilhjv0vi

Thank you.

You said “Please note that containers has no such event”.

This is exactly what i’m speaking about. Currently, containers has no such event, yes, and i’m suggesting an evolution here. I’m spending too much time to fight against the fact that onBeforeRender and onAfterRender are not available for every “things” having something to do with the dom tree (perhaps not ALL things).

I wondering if i’ll not try to patch webix on my side, hope i’ll not discover a technical reason justifying why theses 2 events are not available every where.

I can see in the webix source code that there is 51 lines having “render:” and after quickly browse theses functions, i consider it’s an entry point to investigate and try to make 2 new events. Just for testing, let’s choose different events name, so no side effect.

* onBeforeDomInsert
* onAfterDomInsert

In the same idea, when something is removed. But seem’s it’s more work for a patch.

* onBeforeDomRemove
* onAfterDomRemove

As a webix user/developer, having theses events available everywhere is a big win of time here, because it’s a uniq entry point for lazy initialization, always the same events, no more need to use onViewShow here, onAfterRender another place, or having to maintain a big amount of code on top of webix with my own widgets so i can make onAfterRender available every where by example.

Thank you for reading.

Working with webix since some years now, i just love it. Except this uniq point and related headeacks :smile:

Perhaps a simple Mixin for layouts is enought ?