Enum HtmxSwap
- Namespace
- Ramstack.HtmxToolkit
- Assembly
- Ramstack.HtmxToolkit.dll
Defines the values for the hx-swap attribute.
public enum HtmxSwap
Fields
InnerHtml = 0Replaces the inner HTML of the target element.
OuterHtml = 1Replaces the entire target element with the response.
InnerMorph = 2Morphs the inner HTML of the target element.
OuterMorph = 3Morphs the target element itself.
OuterSync = 4Synchronizes the target element with the response.
TextContent = 5Replaces the text content of the target element.
BeforeBegin = 6Inserts the response before the target element.
AfterBegin = 7Inserts the response before the first child of the target element.
BeforeEnd = 8Inserts the response after the last child of the target element.
AfterEnd = 9Inserts the response after the target element.
Delete = 10Deletes the target element, regardless of the response.
None = 11Does not swap content from the response. Out-of-band items are still processed.
Examples
// Morphing updates the existing elements instead of replacing them,
// so focus and the state of form fields survive the update.
Response.Htmx(htmx => htmx.Reswap(HtmxSwap.OuterMorph));
return PartialView("_Profile", profile);
@* HTMX 1.9.x and 2.x: enable the swap styles from the Toolkit script
and load Idiomorph for true morphing. HTMX 4.x supports them natively. *@
<body hx-ext="ramstack-swap">
...
<script src="https://cdn.jsdelivr.net/npm/idiomorph@0.7.4/dist/idiomorph.min.js"
integrity="sha384-YWh9vmu1Q6BptPp1emqfsNatFASVLolFKP/5f4LWR6eGMLEhBDh1zcwU2OzfVCe9"
crossorigin="anonymous"></script>
</body>