hotwired-laravel / turbo-laravel

This package gives you a set of conventions to make the most out of Hotwire in Laravel.
https://turbo-laravel.com
MIT License
795 stars 48 forks source link

[ADD] `wantsTurboFrame` for `GET` requests #69

Closed bilogic closed 2 years ago

bilogic commented 2 years ago

I'm doing a search function and would like to submit the form as GET so that it updates the URL as well.

Since there is a wantsTurboStream examining the accept header, does it make sense to add wantsTurboFrame to examine for the turbo-frame header? This way, backend will know to send a partial instead of the full render.

bilogic commented 2 years ago

Please ignore above, it appears the turbo middleware is already handling turbo frames.

tonysm commented 2 years ago

You can detect if the request was made targeting a Turbo Frame by checking if there's a Turbo-Frame header in the request (Turbo adds that). Something like this:

if (request()->headers->has('Turbo-Frame')) {
  // handle differently...
}