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: SQSP User for 17 yrs. Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF Digital, building Squarespace Extensions to supercharge your commerce website. Content: Links in my posts may refer to SF Digital products or may be affiliate links. If my advice helped, you can thank me by clicking one of the feedback emojis below. I love coffee too. 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: SQSP User for 17 yrs. Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF Digital, building Squarespace Extensions to supercharge your commerce website. Content: Links in my posts may refer to SF Digital products or may be affiliate links. If my advice helped, you can thank me by clicking one of the feedback emojis below. I love coffee too. 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