Spec-Zone.ru › htmx

HX-Request-Type

Indicates partial or full page request

The HX-Request-Type request header indicates if request targets a specific element or the whole page.

Syntax

HX-Request-Type: partial

// or

HX-Request-Type: full

Values

This header is added automatically.

full

Used when the target is the document body, or when selecting elements from the response (with hx-select).

<!-- If target is body (explicit) -->
<button hx-get=... hx-target="body">

<!-- If target is body (implicit) -->
<a href=... hx-boost="true">

<!-- If selecting elements from response -->
<div hx-get=... hx-select=".content">

Note: hx-boost="true" implicitly sets hx-target="body".

partial

Used when the target is any other element.

<!-- If target is any element (except body) -->
<button hx-get="..." hx-target="#results">...</button>

<!-- If target is not set (defaults to this element) -->
<div hx-post="...">...</div>

Example

Use it on the server to customize response behavior:

request_type = request.headers.get('HX-Request-Type')
if request_type == 'full':
    return render_full_page()
else:
    return render_fragment()

Licensed under the Zero-Clause BSD License.
https://four.htmx.org/reference/headers/HX-Request-Type/

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API