Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Is there a way to implement an infinit scroller without adding javascript ? #270

Answered by adamghill
MayasMess asked this question in Q&A
Discussion options

Hello hello, everything is in the title :).
I'm creating a todo list with all the crud fonctionnallities and it's working really well. The only thing I didn't find how to do without adding javascript, is the infinit scroller.

image

Cheers!

You must be logged in to vote

This is now released in 0.35.0. Documentation is located here: https://www.django-unicorn.com/docs/visibility/. Let me know if you run into any issues with it!

Replies: 4 comments · 6 replies

Comment options

I can't think of a way to do this in Unicorn currently without some custom JavaScript or without a button or link that gets clicked. But, you could create an IntersectionObserver which would be relatively straight-forward and then it could use https://www.django-unicorn.com/docs/actions/#calling-methods to call a view method.

However, would something like the following be useful if it was added to Unicorn?

{% for object in objects %}
<div>{{ object }}</div>
{% endfor %}

<template unicorn:visible="get_new_objects" />
You must be logged in to vote
3 replies
@MayasMess
Comment options

Hi Adam, thank you for your answer.

Will the template tag get trigerred when it is visible on the page and then call the method get_new_objects automatically ?
If it's the case, yeah it would be great.

@adamghill
Comment options

Will the template tag get trigerred when it is visible on the page and then call the method get_new_objects automatically

Yep! That would be the idea. I'll see how easy it is to add that functionality.

@adamghill
Comment options

#271 has a proof of concept and it seems to work pretty well, but I need to do some more testing.

Comment options

This is now released in 0.35.0. Documentation is located here: https://www.django-unicorn.com/docs/visibility/. Let me know if you run into any issues with it!

You must be logged in to vote
2 replies
@MayasMess
Comment options

Thank you Adam, I'll try it today 👍

@MayasMess
Comment options

So I added the span tag after the for loop in the template like in the documentation:
image

But the function is not trigerred when I scroll down to it and make it visible.

This is the view:
image

Is it supposed to work this way ?

Answer selected by adamghill
Comment options

You must be logged in to vote
1 reply
@MayasMess
Comment options

I tried it out on another laptop and it's working well. maybe it was the version that didn't update correctly :/ even though I checked my virtual env and the changes you made were there.
Anyway ^^ thanks a lot :)

Comment options

It work very well.. but why the state loading is not triggered?

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.