|
|
|
|
|
by nickjj
2007 days ago
|
|
> You just do LiveView instead of a regular controller. No duplication. Yes but this is only in the happy case when the client is fully enhanced no? What happens if you hook up a phx click event to increment a like counter. After the page is loaded, if you click the + to increment it while having JavaScript disabled it's not going to do anything right? But with Hotwire Turbo, if you have a degraded client with no JS, clicking the + would result in a full page reload and the increment would still happen. That's progressive enhancement. It works because it's a regular link and if no JS intercepts it, it continues through as a normal HTTP request. |
|
One way to do it would be to in the `mount` function handle normal non-javascript params being sent and a `handle_event` function handle `phx-click`.
I don't know if there is already a way to have `phx-click` with fallback to HTTP in a less "manual" way. It should be possible to make.