# Create callback inside a callback?

**URL:** <https://community.plotly.com/t/create-callback-inside-a-callback/14711>\
**Category:** Dash Python\
**Created:** [October 18, 2018, 5:40pm UTC](https://community.plotly.com/t/create-callback-inside-a-callback/14711 "2018-10-18T17:40:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chebyshev](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@chebyshev](https://community.plotly.com/u/chebyshev)\
**Post date:** [October 18, 2018, 5:40pm UTC](https://community.plotly.com/t/create-callback-inside-a-callback/14711/1 "2018-10-18T17:40:46Z")

</div>

Is it possible to register a new callback while a server is already running:

```python
app = dash.Dash()
app.config.suppress_callback_exceptions = True

app.layout = html.Div(children=[
    html.Button(
        'Add',
        id='add_button',
    ),
    html.Div(id='content'),
])

@app.callback(
    output=Output(component_id='content', component_property='children'),
    inputs=[
        Input(component_id='add_button', component_property='n_clicks'),
    ],
)
def pushed(n):
    if n is None:
        return html.Div()
    content = html.Div(
        id=f'clicked_{n}',
        children=[
            html.Button(
                f'Button_{n}',
                id=f'button_{n}'
            ),
            html.Div(id=f'content_{n}')
        ],
    ),

    print(f'making callback {n}')
    @app.callback(
        output=Output(component_id=f'content_{n}', component_property='children'),
        inputs=[
            Input(component_id=f'button_{n}', component_property='n_clicks')
        ]
    )
    def button_press(nc):
        print(f'callback {n}')
        return f'button {n} pushed {nc} times'
    
    return content

```

I’ve seen differing information about this. The above code doesn’t work, behaving as though the dynamically created callbacks don’t exist.

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [October 18, 2018, 6:02pm UTC](https://community.plotly.com/t/create-callback-inside-a-callback/14711/2 "2018-10-18T18:02:37Z")

</div>

It’s not, see [Dynamic Controls and Dynamic Output Components](https://community.plotly.com/t/dynamic-controls-and-dynamic-output-components/5519)
