will x-ajax be added? #2405
Replies: 3 comments 7 replies
-
I have just the answer for you. https://codepen.io/lomacar/pen/JjJBpeo?editors=1011 Use my grab() function inside the x-data, and supply the function with one or more variables that point to objects. Those objects in turn contain one or more strings which are URLs to you data, like so: const paths = {
items: 'https://fakestoreapi.com/products',
books: 'https://www.googleapis.com/books/v1/volumes?q=Alpine'
} When the data is loaded the x-data will init itself and fill your template. Feel free you use and modify as you please. I suppose it could be made into an Alpine magic function if you wanted to, but it's not necessary. |
Beta Was this translation helpful? Give feedback.
-
👋 creator of Alpine AJAX here. I recently added a lot of new functionality to the package and launched a documentation site. Feedback and contributions are welcome! It would be cool to see some of these features merged into core, but I think it makes just as much sense to keep it third-party. I’m happy to keep the Alpine AJAX project maintained as I’ve got several applications using it. |
Beta Was this translation helpful? Give feedback.
-
I would doubt it. There is a loose plan for an SPA mode of alpine, but it's mostly just outside the scope of alpine now. Livewire works with alpine to provide this functionality to laravel apps. But mainly, just use fetch. Axios is crap, and most cases don't make a lot of sense. Also, I made an Broadly speaking it's just using Alpine kind of in the wrong way I'd say. |
Beta Was this translation helpful? Give feedback.
-
something like https://www.npmjs.com/package/@imacrayon/alpine-ajax
I know vue.js does not have ajax builtin, what's the best(easiest) approach for alpine.js to do ajax calls? fetch? axios? even htmx(for html response), what about alpine.js add x-ajax directly?
Beta Was this translation helpful? Give feedback.
All reactions