Jonathan__ Posted June 2 Posted June 2 (edited) Hi https://toucan-flamingo-cs8n.squarespace.com/ Website password is 'massa' ; without the quotation marks. I have implemented the Zenchef widget on my site on the bottom right corner. Works great. What i would like to do is the open the widget when you click on the button 'reserveer' on the website. Below is what can be found on the zenchef website about this. However i can't figure out how make it work within squarespace. Any help is appreciated. If you want to open the booking widget through a custom button on your website, follow this steps: → To trigger an action on the SDK when a user click on a element for example, simply add a data-zc-action attribute to the element. List of events : open : Open the reservation widget close : Close the reservation widget Example: <button data-zc-action="open">Open widget</button> <button data-zc-action="close">Close widget</button> Edited June 2 by Jonathan__ typo
Lesum Posted June 2 Posted June 2 @Jonathan__ Can you please share the website URL? If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. Sam Web Developer & Digital Designer ☕ Did you find my contribution helpful? Buy me a coffee?
Jonathan__ Posted June 2 Author Posted June 2 https://toucan-flamingo-cs8n.squarespace.com/ Password = massa
Solution Lesum Posted June 2 Solution Posted June 2 @Jonathan__ Squarespace button won't function with the widget. You need to create a button using a code block. To do this, go to the section where you want to add the button, then select "Add Block" > "Code" and insert the following code snippet: <button class ="sqs-block-button-element--medium sqs-button-element--primary sqs-block-button-element" data-zc-action="open">Reserveer</button> If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. Sam Web Developer & Digital Designer ☕ Did you find my contribution helpful? Buy me a coffee?
Jonathan__ Posted June 2 Author Posted June 2 @Lesum Thank you! I assume this won't work for the navigation bar? But that's okay, i will delete that button over there. Also to style this custom button would i do it in the code block, or in the custom css section?
Lesum Posted June 2 Posted June 2 @Jonathan__ This will work for the nav bar. However, it will require some additional custom code. Add the following under Code Injection > Header <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script> $(document).ready(function(){ $('.header-actions-action--cta a').attr('data-zc-action', 'open'); }); </script> You can style the button in the custom CSS section. If you want to add CSS code inside the code block, you have to add it within a <style> </style> block. If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. Sam Web Developer & Digital Designer ☕ Did you find my contribution helpful? Buy me a coffee?
Jonathan__ Posted June 2 Author Posted June 2 @Lesum can i ask you one more question, so i added that button. But it is not aligned horizontally compared to the code block it is in. How would i do that?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment