David2021 Posted January 25, 2022 Share Posted January 25, 2022 Hi there, I have injected some JQuery code into my page in order to set a few conditional fields within a form. The conditional fields are triggered depending on the selection from a radio button as shown below: As you can see when a number other than 0 is selected the conditional fields get displayed. The form works perfectly as expected but the problem is when I switch to form to a lightbox the JQuery seems to stop working and the conditional fields do not appear, no matter the selection. What am I missing here? Any help on this would be appreciated đ  Link to comment
paul2009 Posted January 25, 2022 Share Posted January 25, 2022 The code must wait until the form has loaded, not the page. When the form is on the page, both load at the same time but when it is a lightbox form it won't be added to the page until the form is launched. David2021 1 About: Squarespace Circle Leader since 2017. I value honesty, transparency, diversity and great design âĽ.Work: Squarespace Developer and founder of SF Digital, building the features Squarespace didn't includeâ˘. Content: Links in my posts may refer to SF Digital products or may be affiliate links. Catch up on all the release notes and announcements 2023 [for Circle members only]. There's a public version here too!If I helped, you can thank me by clicking one of the emojis below. If you prefer, you can buy me a coffee.Improve your online store with our extensions. Link to comment
David2021 Posted January 26, 2022 Author Share Posted January 26, 2022 19 hours ago, paul2009 said: The code must wait until the form has loaded, not the page. When the form is on the page, both load at the same time but when it is a lightbox form it won't be added to the page until the form is launched. Thanks Paul, would you have an example of code that would work for recognising if the form is launched or not? I have tried these examples below so far: $('#yui_3_17_2_1_1643211118624_394').on( "load", function() { }); if($('#yui_3_17_2_1_1643211118624_394').is(':visible')){ } Â Link to comment
paul2009 Posted January 26, 2022 Share Posted January 26, 2022 It's more complex than that đ. You'll need a Mutation Observer to detect the changes. About: Squarespace Circle Leader since 2017. I value honesty, transparency, diversity and great design âĽ.Work: Squarespace Developer and founder of SF Digital, building the features Squarespace didn't includeâ˘. Content: Links in my posts may refer to SF Digital products or may be affiliate links. Catch up on all the release notes and announcements 2023 [for Circle members only]. There's a public version here too!If I helped, you can thank me by clicking one of the emojis below. If you prefer, you can buy me a coffee.Improve your online store with our extensions. Link to comment
David2021 Posted January 26, 2022 Author Share Posted January 26, 2022 Ok I'll give that a shot, thanks đ Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment