The post is about a community member who is trying to access a Webstudio Resource variable from an HTML block that adds JavaScript. The comments suggest that the community members have tried different approaches, such as binding the resource variable to an attribute and accessing it from the HTML embed script, or defining a variable in JavaScript and setting its value to the one from Webstudio using a binding. However, some of the approaches did not work for the original poster. The community members discuss potential improvements to the UI and functionality, such as making the expression editor more readable and providing better support for binding variables. There is no explicitly marked answer in the comments.
Hello, I have an HTML block that adds Javascript. But in this one, I need to access a Webstudio Resource variable. But I can't figure out how to do this. Who's tried this?
I think the UI or functionnality could be improve:
1/ In the expression editor, it's not easy to read the code with \n. 2/ It's not easy to understand that it's not possible to type in code when we have bound elements 3/ It would be great to have the ability to bind just one element of a code we we type ${ and maybe with autocompletion of all our variables
agree, we need to think of ways to clarify all this
Add a reply
Sign up and join the conversation on Discord
\n`","dateCreated":"2024-10-13T15:26:30.386Z","dateModified":"2024-10-13T15:26:30.386Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/cdd3ed87-53a0-414a-885a-56b7939e412a","name":"Oleg Isonen","identifier":"cdd3ed87-53a0-414a-885a-56b7939e412a","image":"https://cdn.discordapp.com/avatars/469405813048606720/8b66a5882214c63ee6148fcce3ef8e93.webp?size=256"},"commentCount":0,"comment":[],"position":6,"upvoteCount":0},{"@type":"Comment","text":"Humm... Didn't work for me. Do you have an idea ? ππ»","dateCreated":"2024-10-14T15:00:24.049Z","dateModified":"2024-10-14T15:00:24.049Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/815dd979-0c9f-4685-9378-ea56600dfc5b","name":"omartineau","identifier":"815dd979-0c9f-4685-9378-ea56600dfc5b","image":"https://cdn.discordapp.com/avatars/1003391122640482374/171697515ecc47da92e94754b59aae37.webp?size=256"},"commentCount":0,"comment":[],"position":7,"upvoteCount":0},{"@type":"Comment","text":"It should be in the binding of code","dateCreated":"2024-10-14T16:13:42.523Z","dateModified":"2024-10-14T16:13:42.523Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/25db8895-8f4d-4fa2-9253-599c53976e31","name":"Bogdan","identifier":"25db8895-8f4d-4fa2-9253-599c53976e31","image":"https://cdn.discordapp.com/avatars/394773378101149697/c342af60f86a7ed828d871b397bd204a.webp?size=256"},"commentCount":0,"comment":[],"position":8,"upvoteCount":0},{"@type":"Comment","text":"I need to add to this docs. Note to self","dateCreated":"2024-10-14T16:31:12.816Z","dateModified":"2024-10-14T16:31:12.816Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a3a85f00-1132-4262-8176-1ff92ab9d883","name":"John Siciliano","identifier":"a3a85f00-1132-4262-8176-1ff92ab9d883","image":"https://cdn.discordapp.com/avatars/1141467296532009071/8c83067a661d2916bfb8be5a37677463.webp?size=256"},"commentCount":0,"comment":[],"position":9,"upvoteCount":0},{"@type":"Comment","text":"ie click this plus button. Can you let me know your use case so I can provide a real example in docs?","dateCreated":"2024-10-14T16:34:14.161Z","dateModified":"2024-10-14T16:34:14.161Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a3a85f00-1132-4262-8176-1ff92ab9d883","name":"John Siciliano","identifier":"a3a85f00-1132-4262-8176-1ff92ab9d883","image":"https://cdn.discordapp.com/avatars/1141467296532009071/8c83067a661d2916bfb8be5a37677463.webp?size=256"},"commentCount":0,"comment":[],"position":10,"upvoteCount":0},{"@type":"Comment","text":"Great ! Seems to work. I need to go deeper to implement what I need.","dateCreated":"2024-10-14T17:37:09.018Z","dateModified":"2024-10-14T17:37:09.018Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/815dd979-0c9f-4685-9378-ea56600dfc5b","name":"omartineau","identifier":"815dd979-0c9f-4685-9378-ea56600dfc5b","image":"https://cdn.discordapp.com/avatars/1003391122640482374/171697515ecc47da92e94754b59aae37.webp?size=256"},"commentCount":0,"comment":[],"position":11,"upvoteCount":0},{"@type":"Comment","text":"Hi guys! I'm following this discussion and I tried something really easy.On Body I define a variable = 1 (number)after on an HTML Embed I tried this code:But seems it is not working... I think I miss something","dateCreated":"2024-10-14T20:36:41.706Z","dateModified":"2024-10-14T20:36:41.706Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":12,"upvoteCount":0},{"@type":"Comment","text":"${}","dateCreated":"2024-10-14T20:38:04.911Z","dateModified":"2024-10-14T20:38:04.911Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/25db8895-8f4d-4fa2-9253-599c53976e31","name":"Bogdan","identifier":"25db8895-8f4d-4fa2-9253-599c53976e31","image":"https://cdn.discordapp.com/avatars/394773378101149697/c342af60f86a7ed828d871b397bd204a.webp?size=256"},"commentCount":0,"comment":[],"position":13,"upvoteCount":0},{"@type":"Comment","text":"Sorry Bogdan it was easy. I'm tired tonight! Thanks a lot π","dateCreated":"2024-10-14T20:39:20.040Z","dateModified":"2024-10-14T20:39:20.040Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":14,"upvoteCount":0},{"@type":"Comment","text":"No worries","dateCreated":"2024-10-14T20:39:45.079Z","dateModified":"2024-10-14T20:39:45.079Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/25db8895-8f4d-4fa2-9253-599c53976e31","name":"Bogdan","identifier":"25db8895-8f4d-4fa2-9253-599c53976e31","image":"https://cdn.discordapp.com/avatars/394773378101149697/c342af60f86a7ed828d871b397bd204a.webp?size=256"},"commentCount":0,"comment":[],"position":15,"upvoteCount":0},{"@type":"Comment","text":"I think the UI or functionnality could be improve:1/ In the expression editor, it's not easy to read the code with \\n. 2/ It's not easy to understand that it's not possible to type in code when we have bound elements3/ It would be great to have the ability to bind just one element of a code we we type ${ and maybe with autocompletion of all our variablesBut I know that is a lot of work to improve that","dateCreated":"2024-10-14T20:43:32.208Z","dateModified":"2024-10-14T20:43:32.208Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":16,"upvoteCount":0},{"@type":"Comment","text":"agree, we need to think of ways to clarify all this","dateCreated":"2024-10-14T20:48:13.956Z","dateModified":"2024-10-14T20:48:13.956Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/cdd3ed87-53a0-414a-885a-56b7939e412a","name":"Oleg Isonen","identifier":"cdd3ed87-53a0-414a-885a-56b7939e412a","image":"https://cdn.discordapp.com/avatars/469405813048606720/8b66a5882214c63ee6148fcce3ef8e93.webp?size=256"},"commentCount":0,"comment":[],"position":17,"upvoteCount":0}],"author":{"@type":"Person","url":"https://help.webstudio.is/members/815dd979-0c9f-4685-9378-ea56600dfc5b","name":"omartineau","identifier":"815dd979-0c9f-4685-9378-ea56600dfc5b","image":"https://cdn.discordapp.com/avatars/1003391122640482374/171697515ecc47da92e94754b59aae37.webp?size=256"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0}}]