Join the Webstudio community

Updated 3 months ago

Data Variables - Type Function

At a glance

The community member who posted the original post had an idea to declare functions as Data Variables, which would provide a dedicated place to hold functions instead of using an embed to create them. This would allow adding behavior like () => selectLanguage(this).

In the comments, another community member mentioned an "Invoker commands" proposal from the Open UI project, which would allow defining commands on an instance and invoking them with a button click from anywhere else on the page. This would be a client-side only feature, while Data Variables are used on both the server and client side.

Other community members expressed interest in the ideas and noted that functions are a JavaScript concept, while Invoker commands is a newer HTML concept.

Useful resources
Hello, while I was working with a dropdown that should react with a "onchange" listener. I got an idea that could be nice.
Would be nice if we could declare functions as Data Variables, that way. we would have a place just to hold our functions instead of the need for using an embed to create them.

That way I could add the behavior just like: () => selectLanguage(this).
Attachments
0F493F38-99E1-491C-94AB-B62A02106F30.png
A97AD6C0-71FC-41A4-AAF4-DD99585C2A2B.png
B
w
O
3 comments
We actually have another idea. There is an "Invoker commands" proposal https://open-ui.org/components/invokers.explainer/

And we want to leverage it in builder. So you will be able to define command on some instance and invoke it with button click from anywhere else on the page.

This will be client side only feature while data variables are used in both server and client side.
looks interesting. πŸ™‚ thank you
functions is basically a js concept, invoker commands is the latest html concept
Add a reply
Sign up and join the conversation on Discord