Join the Webstudio community

Updated last month

Use js variable for "Collection"

At a glance

The community members are trying to find a way to bind JavaScript variables to the Collection element in Webstudio. They have described a use case where they need to populate the Collection based on user actions, such as button clicks. The community members have been advised that the only way to achieve this functionality in Webstudio currently is by using a Form, as suggested in the examples and videos with directories. It seems the community members are building a search/filters functionality.

How how to bind js variable to the Collection? If it is not possible, do I need to manually recreate functionality of Collection element in the HTML Embed? What is the best way to achieve functionality of Collection with js variables?
Marked as solution
The only way you can do it right now with webstudio is using a Form, see our examples and videos with directories. Seems lke you are building a search/filters functionalty
View full solution
O
k
4 comments
can't put javascript stuff into webstudio variables right now, so better describe your use case accurately so we can suggest how to do it in a better way
The basic use case: need to populate the Collection based on the user actions (buttons clicks).
For example: there are 3 buttons A, B, C. If user clicks on A then value "a" appended to collection array, if user clicks B then value "b" appended and etc.
Attachment
image.png
The only way you can do it right now with webstudio is using a Form, see our examples and videos with directories. Seems lke you are building a search/filters functionalty
Thank you very much for fast responses!
Add a reply
Sign up and join the conversation on Discord