CoorlasArchitecture Posted July 17 Posted July 17 (edited) Hello All - An interesting Issue here: I have a Page Header Code Injection that triggers a button to open a pop-up scheduling calendar, and it works great here: https://www.coorlasarch.com/contact But when I place the same code injection on another page, all buttons on the page are opening the scheduling calendar here: https://www.coorlasarch.com/ Is there a way to only target the "Book Now" Button on the home page to open the scheduling calendar? The Button's Link is set to URL #google-scheduler Code injection for reference: <style> div.code-block { visibility: hidden; } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> <script> $(document).on('click', '.button-block a', function(event) { event.preventDefault(); $('.code-block button').click(); }); </script> Thank you in advance, Stephen Edited July 17 by CoorlasArchitecture Submitted prematurely
Solution HoaLT Posted July 17 Solution Posted July 17 Change your code to <script> $(document).on('click', '#collection-615ba6582ee8b96aab3a717d .button-block a[href="#google-scheduler"]', function(event) { event.preventDefault(); $('.code-block button').click(); }); </script> to run code only on home page with the button whose href is #google-scheduler Press 👍 or mark my comment as solution if you find my sharing useful 🆒 Squarespace pinchzoom lightbox plugin (affiliate link) 👁🗨 360 degree photo viewer (affiliate link) 📑 Squarespace embed PDF popup (affiliate link)
CoorlasArchitecture Posted July 17 Author Posted July 17 Thank you for your response and efforts on this. Is this code a page header injection or code in the actual section? When added to the page header it reveals a button that is created by a section code I failed to mentioned previously: <!-- Google Calendar Appointment Scheduling begin --> <link href="https://calendar.google.com/calendar/scheduling-button-script.css" rel="stylesheet"> <script src="https://calendar.google.com/calendar/scheduling-button-script.js" async></script> <script> (function() { var target = document.currentScript; window.addEventListener('load', function() { calendar.schedulingButton.load({ url: 'https://calendar.google.com/calendar/appointments/schedules/AcZssZ1pO8pVcGaBrfKVYpLabMPR24pc7r6TJ4W-Cmb2PHIZt5xo_H8GrOXLQE0kSce8K8nGZMAe5Soy?gv=true', color: '#b28e74', label: 'Book', target, }); }); })(); </script> <!-- end Google Calendar Appointment Scheduling -->
CoorlasArchitecture Posted July 17 Author Posted July 17 Thank you, I added the "visibility: hidden;" code prompt from the original page header code injection and now it works perfectly: <style> div.code-block { visibility: hidden; } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> <script> $(document).on('click', '#collection-615ba6582ee8b96aab3a717d .button-block a[href="#google-scheduler"]', function(event) { event.preventDefault(); $('.code-block button').click(); }); </script> Thank you so much for your attention to this - Greatly appreciated! HoaLT 1
HoaLT Posted July 17 Posted July 17 Good to know that CoorlasArchitecture 1 Press 👍 or mark my comment as solution if you find my sharing useful 🆒 Squarespace pinchzoom lightbox plugin (affiliate link) 👁🗨 360 degree photo viewer (affiliate link) 📑 Squarespace embed PDF popup (affiliate link)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment