-
Is there a way to collapse a |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
That's not obvious, but we can use Quasar props to make it work: with ui.expansion('Expansion') as e:
ui.label('Some content')
ui.button('Open', on_click=lambda: e.props('model-value'))
ui.button('Close', on_click=lambda: e.props(remove='model-value')) We should think about improving this API. Similar to |
Beta Was this translation helpful? Give feedback.
-
To collapse an expanded element, is there a ui.run_javascript command that could be executed perhaps? |
Beta Was this translation helpful? Give feedback.
-
Well, using the Quasar method mentioned by @falkoschindler works great. async def exp_btn():
_ = await ui.run_javascript(
"const el = document.querySelector('.__EXP__'); if(el) el.firstChild.firstChild.click(); return el"
)
with ui.expansion("Expansion") as e:
e.classes(add="__EXP__")
ui.label("Some Content")
ui.button("Open/Close", on_click=exp_btn) Just giving you an option, for cases where you really need to work with direct JS, but in your case, use the Quasar methods. |
Beta Was this translation helpful? Give feedback.
-
Thanks! |
Beta Was this translation helpful? Give feedback.
-
I might have forgotten to mentioned it here, but with ui.expansion('Expansion') as e:
ui.label('Some content')
ui.button('Open', on_click=e.open)
ui.button('Close', on_click=e.close) |
Beta Was this translation helpful? Give feedback.
Thanks!
ui.button('Close', on_click=lambda _:setattr(element, 'value', False))
works nicely with 1.1.5.