A search result, a page of a list, a counter: a part of a page that the browser wants to refresh on its own. {fragment 'name'}...{/fragment} names such a part. A normal request renders the whole page, the fragment in its place:
|
PHP |
HTML fragments/response_fragments_1.pad |
Result |
|---|---|---|
|
Orders
The page goes on here. |
A request that adds &padFragment=order-list to the URL gets that fragment and nothing else - the same template serves the full page and the update:
|
PHP |
HTML fragments/response_fragments_2.pad |
Result |
|---|---|---|
|
|
padInclude request: no wrapper, no tidy.$padFragmentOnly = 'order-list'; - for instance when the request carries an HX-Request header.{ajax 'orders', fragment='order-list'} fetches only that fragment of the page into its div.<div hx-get="?orders&padFragment=order-list" hx-trigger="every 5s"> swaps in the fresh list.padFragment when it swaps an element named like the fragment: hx-target="#order-list" sends HX-Target: order-list, and a page with a fragment of that name answers it alone. A page without one renders whole, as it would otherwise. See Htmx.