Infinite scroll
See original GitHub issueHello!
I’m trying to make infinite scroll with Sprig and it looks like it’s working but I want to be sure if everything is good because I have the feeling that it’s not.
So I used information from here:
https://putyourlightson.com/sprig/demo/3
What I did with this is added some htmx information to the button and got this:
<button id="load-more" sprig s-val:offset="{{ offset + _limit }}" hx-trigger="revealed"
hx-swap="afterend" s-target="this" s-swap="outerHTML">Load more</button>
It looks like it’s working in the front-end but it doesn’t work in Sprig playground so I have the feeling that I made something wrong.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Infinite Scroll
Infinite Scroll is a JavaScript plugin that automatically adds the next page, saving users from a full page load. You've likely seen it...
Read more >Infinite Scroll Advantages & Disadvantages | Built In
Infinite scroll is a web design technique where more content automatically and continuously loads at the bottom as users scroll down the page....
Read more >The Infinite Scroll: Why It's So Addictive and How to Break Free
The infinite scrolling design pattern was created by engineer Aza Raskin in 2006. Later refined and further developed into a JavaScript plugin ...
Read more >Infinite Scrolling - Examples - ScrollMagic
Dynamic content pages become scroll magical. An infinite-content page can be achieved by adding a scene that triggers at the bottom of the...
Read more >Infinite Scroll: Let's Get To The Bottom Of This
Infinite pages take the concept of infinite scrolling to a new level. Websites that employ this concept are “one-pagers.” To remove the barrier ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You should use
s-
attributes only, otherwise you’ll get duplicates. But the issue is that you’ve copy-pasted and then changed an example without fully understanding it. Here’s a working example of infinite scroll to get you started.In my entries archive page I have this:
load-more.twig file looks like this:
<div class="row"> {% set entries = craft.entries() .section('articles') .type(_type) .with([ 'featureImage', 'postCategories' ]) .limit(_limit) .offset(offset) %}The file that I’m including looks like this:
I think the problem is with changes that I made in button. It looks like:
<button id="load-more" sprig s-val:offset="{{ offset + _limit }}" hx-trigger="revealed" hx-swap="afterend" s-target="this" s-swap="outerHTML">Load more</button>
In Sprig demos it was like this:
<button id="load-more" sprig s-val:offset="{{ offset + _limit }}" s-target="this" s-swap="outerHTML">Load more</button>
I took hx-trigger=“revealed” hx-swap=“afterend” from htmx docs but I’m not sure if I’m using it in proper way (maybe that’s why I’m getting stuck after loading X entries).