Checking if a view component exists

Hi,

I’m trying to check if a view component exists and I’m getting notted (thechnical term for lost) :slight_smile:

I would have thought that
my app ID as the parent of my views could tell me with a true/false if the component existed as in


$$("app").exists("rsetView")

// having
webix.ui({
    id:"app",
    rows:[
      { view:"toolbar" ...
      { view:"datatable" id:"rsetView"...

What else can I try?
Thanks

also you can try this

var viewExists = !!$$("app").queryView({id:"rsetView"});

@AlenaLisava Thank you! It looks promising.

I also tried

$$("app").index($$("rsetView")));

but if it is not there it gives me an undefined :frowning:

FYI I’m creating the view programmatically and then destructing it when not needed.

thanks for any suggestion

Hello, @Lucaz

The point is that when you try to call $$("rsetView") and there is no element with this id, perceives it as if you are trying to access a non-existent variable.

As a solution, with getChildViews you could find child views of the calling component. And then, for example, use find to hack whether the specific view exists.

Please, check the snippet here: Code Snippet