Jump to content

Trying to Pull Up a Script/Light Box from the Navigation

Recommended Posts

Site URL: https://octopus-glockenspiel-8yae.squarespace.com/

Site URL: https://octopus-glockenspiel-8yae.squarespace.com/

Site URL: https://octopus-glockenspiel-8yae.squarespace.com/

Hey folks. Really having some trouble with this despite feeling like it has a simple solution.

Huge thanks in advance to anyone who can steer me in the right direction here. I'm working on a site for a restaurant - they have code from their online ordering platform that opens a kind of like a lightbox-widget that allows users to order without leaving the page.

I have the functionality working via a link in the body, but I'm trying to launch this via a navigation link. I think it's just syntax I'm having trouble with. Below is what I'm working with. That main script is in a code block in the footer, launches totally fine with that full button class in the body, but if I'm trying to get it to work in the navigation would it be a link with '#upserve-olo-opener' or...how do I fire that same action from the nav?

code to order online:

<script src='https://app.upserve.com/platform/olo-widget.js?kokeshi-restaurant-salem' type='text/javascript' id='upserve-olo-script'></script>

button code: (provided by service)

<button class='upserve-olo-button upserve-olo-opener'>Order Online</button>

 

Site URL: https://octopus-glockenspiel-8yae.squarespace.com/

Password: thanksforthehelp

Thanks!

Link to comment
3 hours ago, bridsandparadise said:

Site URL: https://octopus-glockenspiel-8yae.squarespace.com/

Site URL: https://octopus-glockenspiel-8yae.squarespace.com/

Site URL: https://octopus-glockenspiel-8yae.squarespace.com/

Hey folks. Really having some trouble with this despite feeling like it has a simple solution.

Huge thanks in advance to anyone who can steer me in the right direction here. I'm working on a site for a restaurant - they have code from their online ordering platform that opens a kind of like a lightbox-widget that allows users to order without leaving the page.

I have the functionality working via a link in the body, but I'm trying to launch this via a navigation link. I think it's just syntax I'm having trouble with. Below is what I'm working with. That main script is in a code block in the footer, launches totally fine with that full button class in the body, but if I'm trying to get it to work in the navigation would it be a link with '#upserve-olo-opener' or...how do I fire that same action from the nav?

code to order online:

<script src='https://app.upserve.com/platform/olo-widget.js?kokeshi-restaurant-salem' type='text/javascript' id='upserve-olo-script'></script>

button code: (provided by service)

<button class='upserve-olo-button upserve-olo-opener'>Order Online</button>

 

Site URL: https://octopus-glockenspiel-8yae.squarespace.com/

Password: thanksforthehelp

Thanks!

add this snippet into code injection - footer

document.addEventListener('DOMContentLoaded', function() {
    document.addEventListener("click", function(e) {
        // e.target was the clicked element
        if (e.target && e.target.matches('[href="#upserve-olo-script"]')) {
            document.querySelector(".upserve-olo-button.upserve-olo-opener").click()
        }
    });
});

Also I suggest to hide the second scrollbar of the widget using this

.up-olo-section.up-olo-section {
  overflow-y: hidden;
}

image.png.0a1b5e6f22fe6968ee05b8be4e300e32.png

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Keyword Highlighter
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment
On 12/8/2021 at 5:37 PM, bangank36 said:

add this snippet into code injection - footer

document.addEventListener('DOMContentLoaded', function() {
    document.addEventListener("click", function(e) {
        // e.target was the clicked element
        if (e.target && e.target.matches('[href="#upserve-olo-script"]')) {
            document.querySelector(".upserve-olo-button.upserve-olo-opener").click()
        }
    });
});

Also I suggest to hide the second scrollbar of the widget using this

.up-olo-section.up-olo-section {
  overflow-y: hidden;
}

 

Thank you so much for this!

I'm still a little confused on how to apply this to a link in the navigation. How do I make the navigation link listen for this event or is there a way to create a navigation link via this code injection?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.