-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trigger attribute on dropdowns fire unconditionally across a page #44
Comments
@FelixArokia I verified this. This is not a bug. Since the When either dropdown is changed, a form submission is triggered, and hence you get back both I'm guessing that you were expecting exactly one of Regardless, given that this is the behavior, and given that this cannot be changed, I'd like to know if this behavior is a show stopper for you, so that we can accommodate your case properly. cc @mturoci |
Q-MB has similar use-case. This is what I do (tuned for your example): async def main_page(q: Q):
if not q.client.initialized:
q.user.arg_store_dropdown = 'Store 1'
q.user.arg_item_dropdown = 'Item 1'
q.client.initialized = True
if q.user.arg_store_dropdown != q.args.arg_store_dropdown:
q.user.arg_store_dropdown = q.args.arg_store_dropdown
q.page['store_trigger'] = ui.form_card(box = '1 4 10 1', items = [
ui.text_xl("Store drop down was selected. SUCCESS STORE"),])
elif q.user.arg_item_dropdown != q.args.arg_item_dropdown:
q.user.arg_item_dropdown = q.args.arg_item_dropdown
q.page['store_trigger'] = ui.form_card(box = '1 4 10 1', items = [
ui.text_xl("Item drop down was selected. SUCCESS ITEM"),]) Is there a better way? |
@vopani - thanks for the example. Assuming your example demonstrates "how to identify which dropdown was changed", is this something you commonly need, and why? Why wouldn't you blindly refer to q.args (or q.args copied over to q.user) instead of trying to identify which dropdown changed? |
I actually refactored it to use args blindly: https://github.com/h2oai/q-marketbasket/blob/master/run.py#L634 But I can see why knowing which dropdown changed can be useful too. eg: I have a bar chart. I change a dropdown. The bar chart shows the original values (dotted) and the new values (comparing the state of the chart before the dropdown change and after). The chart would only make sense if I know what dropdown was changed and see the values before/after the change. Whether it's common or not, I'm not sure but I'd say not so common. In most cases, can just use args blindly. |
Thanks @FelixArokia @vopani. Closing. |
Via @FelixArokia
The text was updated successfully, but these errors were encountered: