Resetting page contents without reloading the app

Hello,

I have 2 Pages in my app. I am updating the contents of the page using callback functions. Whenever I go to the second page, it always shows the contents of the previous callback output. Is there a way i can reset the contents to always show the values in the layout before any update by the callback functions?

For example i have a graph in one page with a datepicker component whose default value when loaded is today’s date. A user can change to yesterday’s date and the graph updates its content to yesterday. When the user leaves this page, and then comes back - it still shows yesterday’s date instead of resetting to today’s date. How can i force this reset to happen?

thanks

It would greatly help if you shared some code, without it people that try to help you can only make wild guesses.

When the user leaves this page, and then comes back - it still shows yesterday’s date instead of resetting to today’s date.

The default should be that the user input is “forgotten” once the user leaves the page. Look at the behaviour in the examples for dcc.DatePickerRange: reloading the page resets user input. Such changes should only persists if persistence is explicitly enabled - maybe that is the case here?

sorry i didn’t post the code. This is what I am doing:

       @app.callback(
            Output('graph', 'figure'),
            Output('date_picker', 'date'),
            Input('date_picker', 'date'),
            Input('table', 'selected_rows'),
            State('table', 'data'), #prevent_initial_call=True
        )
        def update_graph(date, selected_rows, data):


            if date is None:
                date = datetime.now().strftime("%Y-%m-%d")

            if len(selected_rows) == 0:
                raise PreventUpdate

            date_object = datetime.strptime(date, "%Y-%m-%d")
            df = pd.DataFrame.from_dict(data)

            fig = go.Figure()
            fig = px.line(df, x='x', y='y')


            # set legend on top of the graph
            fig.update_layout(
                xaxis_title="Time",
                yaxis_title="Value",
                legend_title=None,
                legend=dict(orientation="h", x=0.0, y=1.2, )

            )

            return fig, date 

Doing it this way does not reset the date value when i leave the page and come back to it. I have not set persistence anywhere.