PLAY PODCASTS
The basics: hx-vals
Season 1 · Episode 11

The basics: hx-vals

hx-pod

February 1, 20243m 58s

Audio is streamed directly from the publisher (media.transistor.fm) as published in their RSS feed. Play Podcasts does not host this file. Rights-holders can request removal through the copyright & takedown page.

Show Notes

How do you feel about setting your request values right there inline?

STATIC
<button hx-get="/my/weather/data"
              hx-trigger="click"
              hx-vals='{"location": "01245"}'>
   Click for weather in one static location
</button>

DYNAMIC
<button hx-get="/my/weather/data"
              hx-trigger="click"
              hx-vals='js:{location: document.getElementById("zipcode").value}'>
   Click for weather in one static location
</button>

OR
<button hx-get="/my/weather/data"
              hx-trigger="click"
              hx-vals='js:{location: someJavascriptCalculationFunction()}'>
   Click for weather in one static location
</button>

Topics

htmx javascript programming laravel livewire minimalism coding html simplicity