divar Posted June 28, 2020 Posted June 28, 2020 Site URL: https://www.erheer.com/shop/ariel Hi Squarespace Wizards, I am trying to install a dropdown accordion in the description of a physical product. Unfortunately Squarespace doesn't have the option to add a markdown box in the description of a product(screenshot 1). I have add the code block and the markdown box in the additional Info (screenshot 2) but that shows at the end of the page after all the product photos at the moment. I'd like the dropdown to be a part of the product description itself (screenshot 4) and not at the end of the page. Any assistance would be greatly appreciated. Thanks, Divya
tuanphan Posted June 30, 2020 Posted June 30, 2020 You can add to additional info, then share url again. We can give the code to move it to description divar 1 Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
divar Posted July 1, 2020 Author Posted July 1, 2020 Thanks for the reply. I will share the link once i've figured out how to make the code work outside the develop/edit mode of squarespace. The accordion is working fine on the page in edit mode but when I test it in on a fresh tab, its not.
divar Posted July 1, 2020 Author Posted July 1, 2020 Hi tuanphan, I've added the code to additional info. Please help with adding it to just under the description itself. Also if it's not too much trouble could you help me with closing the + automatically close when another "H" is opened. https://aqua-megalodon-5m3t.squarespace.com/shop/ariel Please let me know if you need any additional info. On 6/30/2020 at 7:04 PM, tuanphan said: You can add to additional info, then share url again. We can give the code to move it to description
tuanphan Posted July 2, 2020 Posted July 2, 2020 55 minutes ago, divar said: july2020 Move it under price, description, variant dropdown or..? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
divar Posted July 2, 2020 Author Posted July 2, 2020 Just after the text ends..Please see photo attached. Also I want the same to happen for all my products, so will I have to post the code on each individual product or can I paste it somewhere else so that it is applied to all the products.
rwp Posted July 2, 2020 Posted July 2, 2020 Can you post your code for the accordion? I can see about closing them when another is opened.
divar Posted July 2, 2020 Author Posted July 2, 2020 Here it is and thanks for working on this! <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script> $(document).ready(function(){ $('.markdown-block .sqs-block-content h3').css('cursor','pointer'); $(".markdown-block .sqs-block-content h3").nextUntil("h3").slideToggle(); $(".markdown-block .sqs-block-content h3").click(function() {$(this).nextUntil("h3").slideToggle();}); }); </script>
tuanphan Posted July 2, 2020 Posted July 2, 2020 (edited) Add to Code Injection Footer <script> $(document).ready(function() { $('.ProductItem-additional .markdown-block').insertAfter('.ProductItem-details-excerpt'); }); </script> and add this to Home > Design > Custom CSS .ProductItem-details .markdown-block { order: 4; } Edited July 2, 2020 by tuanphan Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
rwp Posted July 2, 2020 Posted July 2, 2020 I was just helping someone else today with a similar accordion, but he hasn't been back to test it yet. See if this works. $(document).ready(function() { $('.markdown-block .sqs-block-content h3').addClass('ui-closed').css('cursor', 'pointer'); $('.markdown-block .sqs-block-content h3').nextUntil('h3').slideUp(); $('.markdown-block .sqs-block-content h3').click(function() { if ($(this).nextUntil('h3').is(':hidden')) { $('.markdown-block .sqs-block-content h3').nextUntil('h3').slideUp(); $('.markdown-block .sqs-block-content h3').removeClass('ui-open'); $('.markdown-block .sqs-block-content h3').addClass('ui-closed'); $(this).nextUntil('h3').slideDown(); $(this).toggleClass('ui-closed ui-open'); } else { $(this).nextUntil('h3').slideUp(); $(this).toggleClass('ui-closed ui-open'); } }); }); .markdown-block p { margin-left: 1em; } .markdown-block .ui-closed:before { font-family: monospace; content: "+ "; color: #2DA9C6; } .markdown-block .ui-open:before { font-family: monospace; content: "- "; color: #2DA9C6; }
divar Posted July 2, 2020 Author Posted July 2, 2020 It is working but only after I refresh the page. Somehow when the page loads for the first time, it still shows the text at the end of the page and all opened up like in screenshot 1 & 2. And then when I hit refresh, it works (screenshot 3)
rwp Posted July 2, 2020 Posted July 2, 2020 Try replacing $(document).ready(function() { with window.Squarespace.onInitialize(Y, function () {
divar Posted July 2, 2020 Author Posted July 2, 2020 Tried the code but it doesn't seem to be working. 1st - the script isn't firing when the page first loads 2nd - after I refresh the page, it starts showing in the correct place but is all opened up.
rwp Posted July 2, 2020 Posted July 2, 2020 Sorry, try changing this code <script> $(document).ready(function() { $('.ProductItem-additional .markdown-block').insertAfter('.ProductItem-details-excerpt'); }); </script> to this <script> window.Squarespace.onInitialize(Y, function () { $('.ProductItem-additional .markdown-block').insertAfter('.ProductItem-details-excerpt'); }); </script> This is an issue with ajax loading.
divar Posted July 2, 2020 Author Posted July 2, 2020 Tried but it is doing the same thing. Not firing at first load and then when I refresh, it works but all the sections are opened up. Also this code is in the Code Injection Footer and not header. <script> window.Squarespace.onInitialize(Y, function () { $('.ProductItem-additional .markdown-block').insertAfter('.ProductItem-details-excerpt'); }); </script>
rwp Posted July 2, 2020 Posted July 2, 2020 (edited) OHHHH. I think I see the issue. You might have put some of the CSS in the code injection block. So delete both codes from above replace with this (code injection) <script> window.Squarespace.onInitialize(Y, function() { $('.ProductItem-additional .markdown-block').insertAfter('.ProductItem-details-excerpt'); $('.markdown-block .sqs-block-content h3').addClass('ui-closed').css('cursor', 'pointer'); $('.markdown-block .sqs-block-content h3').nextUntil('h3').slideUp(); $('.markdown-block .sqs-block-content h3').click(function() { if ($(this).nextUntil('h3').is(':hidden')) { $('.markdown-block .sqs-block-content h3').nextUntil('h3').slideUp(); $('.markdown-block .sqs-block-content h3').removeClass('ui-open'); $('.markdown-block .sqs-block-content h3').addClass('ui-closed'); $(this).nextUntil('h3').slideDown(); $(this).toggleClass('ui-closed ui-open'); } else { $(this).nextUntil('h3').slideUp(); $(this).toggleClass('ui-closed ui-open'); } }); }); </script> Then add this to Design -> Custom CSS .markdown-block p { margin-left: 1em; } .markdown-block .ui-closed:before { font-family: monospace; content: "+ "; color: #2DA9C6; } .markdown-block .ui-open:before { font-family: monospace; content: "- "; color: #2DA9C6; } Edited July 2, 2020 by rwp tuanphan, Elzburg and divar 3
divar Posted July 2, 2020 Author Posted July 2, 2020 (edited) I think I am losing the plot here. Just to confirm once again, just the above two pieces of code right and delete everything else? CSS goes in Design < Custom CSS Script goes in Home > Settings > Advanced > Code Injection (Footer) No other piece of code on the product, just the Markdown block in Additional Info? Sorry for being a noob. Edited July 2, 2020 by divar
rwp Posted July 2, 2020 Posted July 2, 2020 Correct, but if you had other code, not related to the accordion, don't remove that. The last code I posted above should move the accordion and make it work how you want.... Hopefully.....
divar Posted July 2, 2020 Author Posted July 2, 2020 Hey sorry I tried but it is not working now at all. Just appearing at the end of the page even if i refresh it.
rwp Posted July 2, 2020 Posted July 2, 2020 Put this in the header code injection <script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script> divar 1
divar Posted July 2, 2020 Author Posted July 2, 2020 It seems to be working now but the accordion in now appearing at the top of the page and not under the description. Also I noticed that the website if taking longer to load, up to 10 seconds.
veganedge Posted July 2, 2020 Posted July 2, 2020 I'm very interested in this fix as well.... If it gets ironed out, would you mind posting full code again?
rwp Posted July 2, 2020 Posted July 2, 2020 Add this to custom CSS .markdown-block { order: 5; } divar 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment