Nested views

I have a custom dialog. Add some child with this way:

local some_stuff=vb:column {}

local var={}

main_window = {vb:column {vb:row{some_stuff}}}

var[1]=vb.row {vb:column{vb:bitmap{id=“bit”,bitmap=“path1”}}}

some_stuff:add_child(var[1])

It’s works fine, but after

some_stuff:remove_child(var[1])

i cannot do again

var[1]=vb.row {vb:column{vb:bitmap{id=“bit”,bitmap=“path1”}}}

There error message with:

std:logic_error: ‘ViewBuilder: a view with id ‘bit’ was already registered to this viewbuilder instance’

Why? What wrong in my code?

Thank you

You also need to clear the id when you remove child because even though you have removed the child from view, it still exists.

In this case you would put this after you remove child:

vb.views[“bit”] = nil

Alternatively you don’t need to specify id=“bit” unless that control is being modified by another part of your code

A big thanx. I’ll try to do this. By the way - the full code is

some_stuff:remove_child(var[1])

var[1]=nil

Perhaps it’s no enough. And “view” object still live? Yeah?

Did i need

vb.views[var[1]]=nil

var[1]=nil

Yes, i use this id to modify view dynamicaly.

Cheers