toolkit

Hx

Sets htmx response headers: redirect, location, refresh, push and replace URL, trigger, retarget and reswap.

Hx:: Phlat\Toolkit\Hx 9 methods

Navigation 5

  • redirect Makes htmx load $url as a full page, then exits.
  • location Makes htmx load $url without a full reload, then exits.
  • refresh Makes htmx reload the page, then exits.
  • pushUrl Pushes $url into the browser history.
  • replaceUrl Replaces the current URL in the browser history.

Swap control 4

  • trigger $target (a CSS selector) dispatches the event there instead of on the requesting element - needed when the requesting element itself gets swapped out before the event would fire.
  • retarget Swaps the response into $selector instead of the requested target.
  • reswap Overrides the swap strategy: `outerHTML`, `beforeend` and so on.
  • reselect Swaps in only the part of the response matching $selector.

Navigation

redirect

exits
Hx::redirect(string $url): never

Makes htmx load $url as a full page, then exits.

Parameters (1)
$url string

Returns never

phlat/src/Toolkit/Hx.php:17

location

exits
Hx::location(string $url): never

Makes htmx load $url without a full reload, then exits.

Parameters (1)
$url string

Returns never

phlat/src/Toolkit/Hx.php:25

refresh

exits
Hx::refresh(): never

Makes htmx reload the page, then exits.

Returns never

phlat/src/Toolkit/Hx.php:33
Hx::pushUrl(string $url): void

Pushes $url into the browser history.

Parameters (1)
$url string
phlat/src/Toolkit/Hx.php:41
Hx::replaceUrl(string $url): void

Replaces the current URL in the browser history.

Parameters (1)
$url string
phlat/src/Toolkit/Hx.php:47

Swap control

Hx::trigger(array $events, ?string $target = null): void

$target (a CSS selector) dispatches the event there instead of on the requesting element - needed when the requesting element itself gets swapped out before the event would fire.

Parameters (2)
$events array
$target ?string = null
phlat/src/Toolkit/Hx.php:56
Hx::retarget(string $selector): void

Swaps the response into $selector instead of the requested target.

Parameters (1)
$selector string
phlat/src/Toolkit/Hx.php:63
Hx::reswap(string $strategy): void

Overrides the swap strategy: `outerHTML`, `beforeend` and so on.

Parameters (1)
$strategy string
phlat/src/Toolkit/Hx.php:69
Hx::reselect(string $selector): void

Swaps in only the part of the response matching $selector.

Parameters (1)
$selector string
phlat/src/Toolkit/Hx.php:75