Button is not working after refresh or page switch #3140
Replies: 2 comments 9 replies
-
Hi @Swasthik-Jain, Please try to provide a minimal executable example. This allows us and the community to help more efficiently. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Thank you for your response. Yes, your approach works well, but the issue is that it reloads whenever the page is refreshed or when switching pages. from nicegui import ui
kpi = ui.right_drawer()
async def toggle_drawer():
kpi.toggle()
async def kpi_panel():
global kpi
with ui.right_drawer(value=False) as kpi:
ui.label('Drawer')
return kpi
@ui.page('/')
async def page():
ui.button('Show drawer', on_click=toggle_drawer)
await kpi_panel()
ui.run() This setup functions effectively, similar to your approach, as we are simply displaying labels, and it works well.
|
Beta Was this translation helpful? Give feedback.
-
Question
I wanted to achieve this
if toggled, do a first load
if toggled again, hide
if toggled again, show the previously loaded kpi, run a refresh in background --> should be much faster and updates values if changes have occurred
I have a main page called search.py from there I'm calling
I have another page where I defined kpi_panel in kpi.py
When the page first loads toggling function works fine[show/hide] and even the close button works fine
if I switch to any other page or refresh the page, I'm not able to trigger the kpi_panel again [ button will not work]
I need your guidance on this matter how to achieve above statements stated in the beginning.
Beta Was this translation helpful? Give feedback.
All reactions