Join the Webstudio community

Updated 2 months ago

Any workarounds for global variables?

At a glance

The community member has a Radix switch on their page and wants to display data in their collection accordingly when the switch is toggled. The issue is that the switch data variable is only available to the children of the switch instance, but the community member would like to access the current value of this variable on all components on the page. A community member suggests a workaround of submitting a form with the GET method to the current page so that system.search gets updated and can be used anywhere on the page. The community member confirms that this approach works for them.

I have a Radix switch on my page.
When I toggle the switch, I want to display data in my collection accordingly (with a conditional expression).
My issue is that the switch data variable is only available to the children of the switch instance, but I would like to access the current value of this variable on all components on the page.
Is there a workaround I can use to achieve this?
B
A
2 comments
Current approach is to submit a form with get method to current page so system.search get updated and can be used anywhere on the page.
Thanks a ton @TrySound!
I was previously trying to replace query parameters using js in the expression editor, but that wasn't working.
A form submit works!
Add a reply
Sign up and join the conversation on Discord