Skip to content

Response

Available methods:

setPushUrl()

Sets the value in HX-Push-Url header. Pushes a new url into the history stack.

$this->response->setPushUrl('/pushed-url');

setReplaceUrl()

Sets the value in HX-Replace-Url header. Replaces the current URL in the location bar.

$this->response->setReplaceUrl('/replaced-url');

setReswap()

Sets the value in HX-Reswap header. Allows you to specify how the response will be swapped. See hx-swap for possible values.

$this->response->setReswap('innerHTML show:top showTarget:#another-div');

setRetarget()

Sets the value in HX-Retarget header. A CSS selector that updates the target of the content update to a different element on the page.

$this->response->setRetarget('#another-div');

setReselect()

Sets the value in HX-Reselect header. A CSS selector that allows you to choose which part of the response is used to be swapped in. Overrides an existing hx-select on the triggering element.

$this->response->setReselect('#another-div');

triggerClientEvent()

Allows you to set the HX-Trigger header.

This method has two parameters:

  • name
  • params
$this->response->triggerClientEvent('showMessage', ['level' => 'info', 'message' => 'Here Is A Message']);