pub struct HxLocation { /* private fields */ }Expand description
Builder for HX-Location header bodies.
HX-Location lets you instruct htmx to perform a navigation without a full
page reload while still providing extra context (target selector, swap mode,
request headers, etc.). Use Htmx::redirect_with_location
to send the resulting header.
Implementations§
Source§impl HxLocation
impl HxLocation
Sourcepub fn new(path: impl Into<String>) -> Self
pub fn new(path: impl Into<String>) -> Self
Create a new HX-Location builder pointing to the provided path.
Sourcepub fn target(self, selector: impl Into<String>) -> Self
pub fn target(self, selector: impl Into<String>) -> Self
Override which element receives the swap.
Sourcepub fn source(self, selector: impl Into<String>) -> Self
pub fn source(self, selector: impl Into<String>) -> Self
Set the selector for the element that should be treated as the source.
Sourcepub fn event(self, event: impl Into<String>) -> Self
pub fn event(self, event: impl Into<String>) -> Self
Specify an event name to trigger on the client before navigation.
Sourcepub fn handler(self, handler: impl Into<String>) -> Self
pub fn handler(self, handler: impl Into<String>) -> Self
Provide a custom client-side response handler.
Sourcepub fn select(self, selector: impl Into<String>) -> Self
pub fn select(self, selector: impl Into<String>) -> Self
Restrict the response fragment that htmx should swap.
Sourcepub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
Add a custom header to the follow-up request.
Sourcepub fn headers<I, K, V>(self, headers: I) -> Self
pub fn headers<I, K, V>(self, headers: I) -> Self
Extend the custom headers with any iterator of key/value pairs.
Sourcepub fn values<T>(self, values: T) -> Result<Self>where
T: Serialize,
pub fn values<T>(self, values: T) -> Result<Self>where
T: Serialize,
Serialize any value into the HX-Location values object.
Sourcepub fn disable_push(self) -> Self
pub fn disable_push(self) -> Self
Prevent htmx from pushing a new history entry.
Trait Implementations§
Source§impl Clone for HxLocation
impl Clone for HxLocation
Source§fn clone(&self) -> HxLocation
fn clone(&self) -> HxLocation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more