Multiple instance of a window widget.

The window is instantiated from it’s own class and there may be multiple instances at the same time. The problem is that i can not set any id’s of the window’s content, as new instances after the first window is shown will reported that the id’s are not unique. As a work around for the window i created a new uid as the window’s id and references it on the close button click event. Is this the way to resolve this, or am i missing something ?

example: Code Snippet

Hello,

You can omit fixed IDs at all and the widget will get a unique auto-generated id, created with the same webix.uid(). You can still close this window on clicking the inner button by referring to it as a button’s top parent:

 view:"button", click: function(){ this.getTopRarentView().close() }

Please, check the snippet: https://webix.com/snippet/653f32ff

Great helga.

I now have a non-modual window which i can instantiate. But i need to disable hide when you press the ESC key. The window contains multiple forms and it’s easy to close the window by mistake when you try to0 escape out of an open combo or select box, also the window is not disposed when you hit the ESC key.

I have a similar problem. I’ve created a chart view (by defining axes, colors, tooltips etc) and I want to instantiate it twice and have different data (but of the same format, for example CPU utilization from two severs) plotted in two charts.

First I’ve accidentally used the same ID for both charts. When calling $$('chart').parse(data.cpu), none of the charts plotted anything, because of the duplicate ID. I think this should generate an error or warning message.

After reading this post, I’m thinking about not using explicit IDs, but letting Webix generate them automatically. But then how can I identify which chart to call the .parse method on, without defining specific IDs? With other component frameworks, I would just instantiate the chart component twice and add the two instances to a common parent view, but apparently this is not possible with Webix.

While already instantiated components cannot be reused (e.g. placed into different app parts), you can easily reuse the same configuration:

var config = { view:"chart", ...}
webix.copy(config)

And find the view in the necessary layout with the queryView method:

top.queryView({view:"chart"})

Here’s a simple snippet: Code Snippet

Thank you, .queryView() solved the problem! (Even without webix.copy(), is it necessary?)

Yes, webix.copy() is highly recommended for wrapping configurations and data sets that are going to be reused. Because Webix logic can modify the JSON objects - change properties, modify records - and the subsequent widgets can receive the wrong config/data.

The above sample is quite simple, so it works well without copying.