Modify layout on document

I want to ask, how we can replace a layout by another layout on the same document by click a button.
Now, i do something like

def change(): 
      curdoc().children[1].children[1].children[0].children[2] = new_plot_new_slider.
button.on_click(change)

But it seems too slow, if i have a layout complex (many sliders, many plots).
I don’t know if there is another solution

Well, you have not stated what version you are using. If less than 1.1 then my first suggestion is to upgrade to version 1.1 or later, since that release saw an overhaul of the layout system.

But even then, five layers of nesting objects is getting to be outside the use cases we had in mind for Bokeh layouts (e.g. most “Shiny” dashboards are something like one column of widgets next to a grid of plots, and that is the space we were aiming for). My best suggestion is to break things up and have multiple roots in your document, that each get inserted in to a page template individually. That way each individual sub-layout is less nested and less complicated. An example of using templates with Bokeh server apps is here:

bokeh/examples/app/dash at branch-3.0 · bokeh/bokeh · GitHub