Jump to content

JQUERY help needed!

Recommended Posts

Site URL: https://corn-apricot-zn88.squarespace.com/personnal

I have a script on my site that allows HTML to be used in BLOG titles. 

The issue is that I am also using the Squarewebsites "Lazysummaries" to have more than 30 show. 

The AJAX works for the first 30, then it does not work. you can see at "Carrie" that her text is not split. (the 3-4 before her did not need a second line). I have tried various versions of adding .lazy-summary to the script  but nothing works and finding out what I need to do to get this working is beyond my skill set. 

This is the code: 

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script>
$(function(){
  $(".summary-title").each(function(){
    $(this).html($(this).text());
  });
});
</script>

 

no PW on site right now. 

 

Edited by deaton72
Link to comment
Just now, deaton72 said:

Site URL: https://corn-apricot-zn88.squarespace.com/personnal

I have an AJAX script on my site that allows HTML to be used in BLOG titles. 

The issue is that I am also using the Squarewebsites "Lazysummaries" to have more than 30 show. 

 

Could you tell us more about the issue/conflict with the plugin and your script

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

@bangank36

It works for the first 30 summary items, but then won't work. 

Because I am using the LAZYSUMMARIES script to load more than 30 I think that the .summary-title, may be called something else past 30, but I don't know what that is. 

On this page: https://corn-apricot-zn88.squarespace.com/people  

The html has the title divided into two lines of text, one red and one black. Carrie (first one in 6th row) and everyone after does not work. 

Link to comment
On 11/1/2021 at 3:04 PM, deaton72 said:

I have an AJAX script on my site that allows HTML to be used in BLOG titles. The issue is that I am also using the Squarewebsites "Lazysummaries" to have more than 30 show. 

The AJAX works for the first 30, then it does not work. 

The jQuery script in your question doesn't use Ajax or take the 'lazy loading' into account. It runs once when the page loads the first 30 items. However, it doesn't run again when additional summary items are added with Ajax.

The code needs to be amended to run whenever summary items are added. You can do this by using the hooks built into Lazy Summaries (see below) or by using a mutation observer to look for new elements.

  allItemsAddedFunction: function(sum_block, jsonData) {
            //runs after all of loaded items appended to summary block
        },
        refreshFunction: function(sum_block, jsonData) {
            //runs after refresh summary block (appending items, sorting..)
        }

It's worth noting that the script above was written in 2016 when jQuery 2.2.2 was current. However, this now has known security vulnerabilities and should be replaced with a newer, safer version.

Edited by paul2009

About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥.
Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. 
Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional.

Link to comment
  • deaton72 changed the title to JQUERY help needed!

@paul2009  Okay. I tried to add the hooks with the code for the html call in between. This is also what a friend told me to do (after I showed him).

Nothing is happening! I feel like something is missing at the front end. I don't know anything about hooks and minimal about these scripts. Just enough to mess things up 🙂  

 

 

allItemsAddedFunction: function(sum_block, jsonData) {$(function(){
  $(".summary-title").each(function(){
    $(this).html($(this).text());
  });
});  
            //runs after all of loaded items appended to summary block
        },
        refreshFunction: function(sum_block, jsonData) {$(function(){
  $(".summary-title").each(function(){
    $(this).html($(this).text());
  });
});  
            //runs after refresh summary block (appending items, sorting..)
        }

 

Link to comment
  • 1 year later...

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.