No video

HTMX in Laravel - AJAX calls with HTML

  Рет қаралды 15,535

Andre Madarang

Andre Madarang

Күн бұрын

HTMX is a simple way to perform AJAX calls and update DOM elements using HTML attributes and no JavaScript. In this video, we'll take a look at a few practical examples of using HTMX within a Laravel app.
GitHub Repo: github.com/dre...
0:00 - Intro and Basics
5:25 - Contact Form Example
15:27 - Users List and Form Example
22:46 - Users Search and Filter Example
LINKS
My courses: codewithdre.com
Sign up for my newsletter: andremadarang.c...
My website: andremadarang.com
Twitter: / drehimself
GitHub: github.com/dreh...
CodePen: codepen.io/dreh...

Пікірлер: 26
@shofada
@shofada Жыл бұрын
HTMX feels natural. It is like this is how it should have been all along.
@naranyala_dev
@naranyala_dev Жыл бұрын
request: full series of Laravel + HTMX
@tanzimibthesam5861
@tanzimibthesam5861 Жыл бұрын
htmx with Alpine should be a gem combo alongside Laravel
@drehimself
@drehimself Жыл бұрын
Yeah, seems like they would work well together.
@zaimcodes
@zaimcodes 6 ай бұрын
Glad you clarified the main use case between both HTMX and Livewire cause I was getting the intuition it looks and works like Livewire... The concept is still the same but the implementations are both principally different
@hanymax
@hanymax Жыл бұрын
i love the way you explain things thanks for you great effort
@cristianbilu
@cristianbilu Жыл бұрын
For the contact form example what i like to do is create a wrapper around the form that will contain your "#response" element and the form itself, i put hx-target="this" and hx-swap="outerHTML" on the wrapper and no target and swap on the form so it can bubble up to the wrapper, extract it into a partial or component and render the entire partial/component as the response. In this way you will always has a fresh form when you it is a success response and if i have errors i just flash the old input with session()->flashInput() so i can use the `old(VALUE, DEFAULT)` helper. Like you would do normally with blade and redirects
@BogosortLife
@BogosortLife Жыл бұрын
Stuff starts to get really ugly/crazy at 14:29 LOL, but the overall solution is quite interesting. I would use it on small websites for sure. Thanks for share, Andre 👍
@Sandeep-jo6ve
@Sandeep-jo6ve Жыл бұрын
More content on laravel htmx alpine
@user-hj5mz4lz1x
@user-hj5mz4lz1x 8 ай бұрын
great video, thanks! I like how you keep the errors in the editing.
@nftsparatodos1274
@nftsparatodos1274 Жыл бұрын
Thanks for the excellent first approach to this new tool n_n
@dimatall
@dimatall 11 ай бұрын
Hmtx is cool for ui stuff to show, hide, filter. For forms I would use livewire. Its just much simpler than writing everything on your own.
@focusplanets4818
@focusplanets4818 11 ай бұрын
May i know why you refresh the page when you make changes in the response html file.
@alikaram98
@alikaram98 7 ай бұрын
Hi thank's for this video a have question I used htmx to delete and the deletion operation is done successfully, but the list is not updated. In your opinion, the reason is that file web.php is used instead of file api.php for routing?
@alejandroulisessanchezgame6924
@alejandroulisessanchezgame6924 11 ай бұрын
How htmx can be use for a CRUD pure laravel or can olnly be use through api?
@MangukiyaVipul
@MangukiyaVipul Жыл бұрын
Thank you for sharing Please let me font and other extensions that you used in visual studio code Thanks
@syahnurnizam1755
@syahnurnizam1755 Жыл бұрын
Looks like this solution is much more complicated than using Laravel Livewire
@user-wl3lk4hy9h
@user-wl3lk4hy9h 7 ай бұрын
datatable need to update with htmx version
@shubhamsahuSD
@shubhamsahuSD Жыл бұрын
Awesome... Can i edit ajax header too
@drehimself
@drehimself Жыл бұрын
I'm not sure if you can change the headers... Here's more info on headers in the docs: htmx.org/docs/#request-headers
@hussainzayaan8184
@hussainzayaan8184 Жыл бұрын
What web server are you using? When I do the api call as shown in the first part, I get the response in 100ms give or take, but you got in 16ms, any idea why there is a huge perf gap?
@drehimself
@drehimself Жыл бұрын
I'm using Valet locally. Not sure what could be causing your local server to be slow.
@prezes4478
@prezes4478 6 ай бұрын
I know 5 months have passed since you asked this, but from your description i guess you are using Windows or WSL. From my experience, Laravel runs smoothly on Linux and Mac, while on Windows it usually gets kinda sloppy.
@AndiKod
@AndiKod 9 ай бұрын
The thing is that it's not "doing stuff in htmX" but in Laravel PHP, ...while recieving Ajax calls from a webpage (one way or another). It goes the same in the others demos using Python, Rust, Go or whatever. All the hype like "switch from React to Htmx" sounds like internet attention as you can't compare a JS framework that actually do everything with ajax calls that need a backend to actually do something. Htmx alone is like the Tailwind version of jQuery!
@LoudMouth_
@LoudMouth_ 7 ай бұрын
Well yea, that's the point. YOU don't have to do anything (mostly) in the front-end with HTMX. Instead of passing JSON to the front end which requires an entire framework to unpack and render into HTML while managing a client version of state why not just send the HTML directly from the back end where the state is managed by the server? Even with react, you still need to process the data to send back from the server, the only difference is it's the HTML which can be inserted directly into the DOM.
@adonespitogonaif
@adonespitogonaif Жыл бұрын
Too much code duplication. And if you create partials/templates for each part of your view that will be messy too
Jeremy McPeak's Larabits - HTMX May Be All You Need
15:22
Laracasts
Рет қаралды 11 М.
Parenting hacks and gadgets against mosquitoes 🦟👶
00:21
Let's GLOW!
Рет қаралды 12 МЛН
Little brothers couldn't stay calm when they noticed a bin lorry #shorts
00:32
Fabiosa Best Lifehacks
Рет қаралды 18 МЛН
OMG what happened??😳 filaretiki family✨ #social
01:00
Filaretiki
Рет қаралды 11 МЛН
Joker can't swim!#joker #shorts
00:46
Untitled Joker
Рет қаралды 38 МЛН
Blueprint - Laravel Code Generation tool
16:23
Andre Madarang
Рет қаралды 42 М.
HTMX - What they don't want you to know!
13:28
CoderOne
Рет қаралды 83 М.
HTML Templates Instead Of Reactivity | Prime Reacts
12:42
ThePrimeTime
Рет қаралды 111 М.
NativePHP - Desktop Apps with Laravel
42:40
Andre Madarang
Рет қаралды 42 М.
HTMX for Impatient Devs
8:33
Isaac Harris-Holt
Рет қаралды 51 М.
PHP on the frontend! No more Javascript!
14:47
Aaron Francis
Рет қаралды 120 М.
HTMX and the View Transitions API
20:21
BugBytes
Рет қаралды 14 М.
HTMX & Go with ThePrimeagen | Preview
15:58
Frontend Masters
Рет қаралды 151 М.
htmx in 100 seconds
2:27
Fireship
Рет қаралды 1,1 МЛН
Top 10 CSS One Liners That Will Blow Your Mind
13:34
developedbyed
Рет қаралды 939 М.
Parenting hacks and gadgets against mosquitoes 🦟👶
00:21
Let's GLOW!
Рет қаралды 12 МЛН