function Htmx::pushUrl
Creates a `data-hx-push-url` attribute.
This attribute instructs HTMX to control URLs in the browser history.
Use a boolean when this attribute is added along with ::get
- true: pushes the fetched URL into history.
- false: disables pushing the fetched URL if it would otherwise be pushed due to inheritance or hx-boost.
Use a URL to cause a push into the location bar. This may be relative or absolute, as per history.pushState()
Parameters
bool|\Drupal\Core\Url $value: Use a Url object or a boolean, depending on the use case.
Return value
static Returns this object to allow chaining methods.
See also
https://htmx.org/attributes/hx-push-url/
File
-
core/
lib/ Drupal/ Core/ Htmx/ Htmx.php, line 664
Class
- Htmx
- Presents the HTMX controls for developers to use with render arrays.
Namespace
Drupal\Core\HtmxCode
public function pushUrl(bool|Url $value) : static {
$url = $value === FALSE ? 'false' : 'true';
if ($value instanceof Url) {
$url = $this->urlValue($value);
}
$this->createStringAttribute('hx-push-url', $url);
return $this;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.