简体   繁体   中英

htmx: Endless scrolling via "revealed" does not work

I want to use htmx hx-trigger="revealed" to implement endless scrolling.

I send this html to the browser. In this case Note-20 should load the next note (Note-19):

    <h1 class="">Note-20</h1>
    <p class="">foo</p>
    <div hx-get="/note/19/" hx-trigger="revealed" hx-swap="outerHTML" class=""></div>

The URL /note/19/ returns roughly the same HTML: it contains the data of Note-19 and at the end it tells the browser to load Note-18 on "revealed".

This works for the first notes. But then it stops.

What could be the reason?

Update

I create a simple demo application to show how you could use htmx with Django: django-htmx-fun

I found a solution: In above code the <div> which triggers the loading via hx-get is empty.

If I add some content (for example "..."), then it works.

I guess my browser (Chrome) does not render the empty <div> and thus the revealed event is not triggered.

With a non-empty <div> it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM