Question:
How do I have a custom OnClick element for a button that is on multiple dynamic pages? The OnClick is interacting with a 3rd party widget. The OnClick code would be:
onclick="Widget.open(‘DIFFERENT-FOR-EACH-PAGE’);”
Product:
Wix Editor
Question:
How do I have a custom OnClick element for a button that is on multiple dynamic pages? The OnClick is interacting with a 3rd party widget. The OnClick code would be:
onclick="Widget.open(‘DIFFERENT-FOR-EACH-PAGE’);”
Product:
Wix Editor
To set a custom onClick
event for a button across multiple dynamic pages in Wix, enable Velo (Dev Mode) and use the wixLocation
API to determine the current page. Assign a unique widget key based on the page identifier, then dynamically set the button’s onClick
event using $w("#customButton").onClick(() => { Widget.open(widgetKey); });
. This ensures that each dynamic page triggers the correct third-party widget without manually modifying each page. Let me know if you need further refinements.
Thank you!
What type of item in the CMS dataset would I use for the widgetKey and how do I call that item?
Use a text field in your CMS to store the widget key for each dynamic page. When the page loads, retrieve this key from the dataset and assign it dynamically to the button’s click event. This way, each page automatically triggers the correct widget without requiring manual updates.
This gives me the following errors. I apologize but I am very new to this:
error: no-undef: ‘Widget’ is not defined. (3:34)
error: no-undef: ‘widgetKey’ is not defined. (3:48)
If you want I can help you with this over a meeting.
I have everything working now thanks to your advice as well as other resources, but I am receiving 2 errors in the Javascript console that seem to be stopping this widget from working:
Error 1
Invalid ‘X-Frame-Options’ header encountered when loading ‘https://fevo-enterprise.com/’: ‘ALLOW-FROM https://www.MYSITEURL.com’ is not a recognized directive. The header will be ignored.
Error 2
Refused to display ‘https://fevo-enterprise.com/’ in a frame because it set ‘X-Frame-Options’ to ‘sameorigin’.
Any thoughts on this?