HTMX in Laravel - AJAX calls with HTML

Поділитися
Вставка
  • Опубліковано 9 лис 2024

КОМЕНТАРІ • 27

  • @shofada
    @shofada Рік тому +29

    HTMX feels natural. It is like this is how it should have been all along.

  • @naranyala_dev
    @naranyala_dev Рік тому +14

    request: full series of Laravel + HTMX

  • @tanzimibthesam5861
    @tanzimibthesam5861 Рік тому +13

    htmx with Alpine should be a gem combo alongside Laravel

    • @drehimself
      @drehimself  Рік тому +4

      Yeah, seems like they would work well together.

  • @zaimcodes
    @zaimcodes 8 місяців тому

    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

  • @cristianbilu
    @cristianbilu Рік тому +1

    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

  • @winter-survivor
    @winter-survivor Рік тому +2

    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 Рік тому +5

    More content on laravel htmx alpine

  • @hanymax
    @hanymax Рік тому +3

    i love the way you explain things thanks for you great effort

  • @RezaOpdebeeck
    @RezaOpdebeeck 10 місяців тому

    great video, thanks! I like how you keep the errors in the editing.

  • @dimatall
    @dimatall Рік тому

    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.

  • @nftsparatodos1274
    @nftsparatodos1274 Рік тому

    Thanks for the excellent first approach to this new tool n_n

  • @alikaram98
    @alikaram98 10 місяців тому

    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?

  • @LatenightDev
    @LatenightDev Місяць тому

    Thankyou

  • @MangukiyaVipul
    @MangukiyaVipul Рік тому

    Thank you for sharing
    Please let me font and other extensions that you used in visual studio code
    Thanks

  • @focusplanets4818
    @focusplanets4818 Рік тому

    May i know why you refresh the page when you make changes in the response html file.

  • @shubhamsahuSD
    @shubhamsahuSD Рік тому

    Awesome...
    Can i edit ajax header too

    • @drehimself
      @drehimself  Рік тому +1

      I'm not sure if you can change the headers... Here's more info on headers in the docs: htmx.org/docs/#request-headers

  • @alejandroulisessanchezgame6924

    How htmx can be use for a CRUD pure laravel or can olnly be use through api?

  • @syahnurnizam1755
    @syahnurnizam1755 Рік тому +1

    Looks like this solution is much more complicated than using Laravel Livewire

  • @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 9 місяців тому

      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.

  • @KhantSiThuPhyo-c5c
    @KhantSiThuPhyo-c5c 10 місяців тому

    datatable need to update with htmx version

  • @AndiKod
    @AndiKod 11 місяців тому

    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_ 9 місяців тому +1

      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