Spec-Zone.ru › htmx

HX-Target

Identifies element that will receive response

The HX-Target request header identifies the element that will receive the response.

This header is only included when a target is specified.

Format: <tag>#<id> (e.g. div#results) or just <tag> for elements without an ID.

Syntax

The header is included as follows:

HX-Target: div#results

Return different content for different targets:

target = request.headers.get('HX-Target')
if target == 'div#sidebar':
    return render_template('sidebar_content.html')

See Also

  • hx-target
  • HX-Retarget

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

Spec-Zone.ru

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