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:#another-div:top');

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 headers: HX-Trigger, HX-Trigger-After-Settle or HX-Trigger-After-Swap.

This method has 3 parameters: * name * params * method - which can be one of: receive (default), settle, swap.

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

For more information, please see hx-trigger.