imacrayon / alpine-ajax

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

History push on x-target event #33

Closed adamkiss closed 11 months ago

adamkiss commented 1 year ago

Hi, I was playing with this today, and I like it so far, so thank you :)

If I enhance links (a la wire:navigate or htmx-boost) or use alpine ajax for filtering (involving get queries), is it on me to manually manage history / push/replace URLs, or do I have an error in the code? I haven't found anything about the history in the docs

adamkiss commented 1 year ago

I just realised that in #19 you cover the filtering use case (manage history yourself), so that part's answered. Is it the same for links enhanced with x-target?

imacrayon commented 1 year ago

Yeah right now Alpine AJAX doesn't cover this use case. It's definitely something I'm interested in, but I'm waiting to see how things shake out over on the Alpine.js repo. The reason being that wire:navigate and the query string history stuff in Livewire are already powered by an Alpine plugin under the hood, and I think Caleb intends to make both of those plugins official first-party plugins eventually. If that ends up being the case I don't want to build an Alpine AJAX API that could be incompatible with the first-party plugins.

If you're wanting to implement SPA-like navigation right now with Alpine AJAX, Classic Turbolinks still works well, or I like to drop https://instant.page/ into my projects; I think preloaded links go a long way in making apps feel fast without having to mess with the history push state stuff.

adamkiss commented 1 year ago

Yeah right now Alpine AJAX doesn't cover this use case. It's definitely something I'm interested in, but I'm waiting to see how things shake out over on the Alpine.js repo. The reason being that wire:navigate and the query string history stuff in Livewire are already powered by an Alpine plugin under the hood, and I think Caleb intends to make both of those plugins official first-party plugins eventually. If that ends up being the case I don't want to build an Alpine AJAX API that could be incompatible with the first-party plugins.

Fair enough, that makes sense

If you're wanting to implement SPA-like navigation right now with Alpine AJAX, Classic Turbolinks still works well, or I like to drop https://instant.page/ into my projects; I think preloaded links go a long way in making apps feel fast without having to mess with the history push state stuff.

I'd just use htmx if that was the case, but I thought - I already have a thing doing ajax/merge thing (alpine-ajax) installed, I might as well speedup the browsing, you know