imacrayon / alpine-ajax

An Alpine.js plugin for building server-powered frontends.
https://alpine-ajax.js.org
MIT License
561 stars 12 forks source link

Infinite Scroll pattern #8

Closed imacrayon closed 1 year ago

imacrayon commented 1 year ago

Infinite scroll is tricky because it requires that we append new server content rather than replace it. In the interest of keeping things simple I intended to allow only replacing DOM content in Apline AJAX, but it looks like we might need to support additional ways to add content to the page.

imacrayon commented 1 year ago

Being able to append elements to a target would also improve the Notifications example. Right now the implementation just replaces the same message on the page when you spam the button.

imacrayon commented 1 year ago

My plan right now is to add support for an arrange attribute. Supported values would be before, prepend, replace, append, after, delete.

This attribute could be added to an AJAX Component and it would control the way incoming content is handled by that component. Essentially before, prepend, append, after, would take the innerHTML of the incoming content and insert it in the appropriate place. replace and delete would handle the outerHTML.

I’m open to bike shedding these names.

imacrayon commented 1 year ago

Added in c336e4c