imacrayon / alpine-ajax

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

$ajax with sync: true is broken in version 0.10.x #113

Closed Fak3 closed 1 week ago

Fak3 commented 1 week ago

The call to

$ajax('', {target: 'mylist', body: {}, sync: true})

silently does nothing, no http requests is sent. When i change argument to sync: false, it works correctly.

Alpine ajax version: https://cdn.jsdelivr.net/npm/@imacrayon/alpine-ajax@0.10.4/dist/cdn.min.js Previously tested working version: 0.9.0

imacrayon commented 1 week ago

Hey, I'm not able to reproduce this. I'm I missing something is this pen? https://codepen.io/imacrayon/pen/QWePqee

Fak3 commented 1 week ago

Hey, I'm not able to reproduce this. I'm I missing something is this pen? https://codepen.io/imacrayon/pen/QWePqee

In your example the bug occurs if you change target to 'mylist sync' - i.e also list a target with x-sync attribute. It is pointless, if i understand right, but in previous versions it worked correctly. Now it silently fails.

imacrayon commented 1 week ago

Yeah, targeting the synced element would be redundant, but I want to support it just in case. Sorry, changing the target still seems to work for me though, I updated the pen: https://codepen.io/imacrayon/pen/QWePqee

Fak3 commented 1 week ago

Ah, a side issue that i tried to solve specifying multiple targets is that I want to set different target for $ajax() call which returns an error response. Currently it is not possible, is it correct? I can only do this via x-target.error element attribute which is ignored by $ajax call.

Fak3 commented 1 week ago

Yeah, targeting the synced element would be redundant, but I want to support it just in case. Sorry, changing the target still seems to work for me though, I updated the pen: https://codepen.io/imacrayon/pen/QWePqee

Remove the mock route and watch network tab in dev console - it does not send any request