Correctly set `pending` state with `ActionForm`
This commit is contained in:
parent
b84906e6dc
commit
395336a8c0
|
@ -96,6 +96,11 @@ where
|
|||
self.0.with(|a| a.pending.read_only())
|
||||
}
|
||||
|
||||
/// Updates whether the action is currently pending.
|
||||
pub fn set_pending(&self, pending: bool) {
|
||||
self.0.with(|a| a.pending.set(pending))
|
||||
}
|
||||
|
||||
/// The URL associated with the action (typically as part of a server function.)
|
||||
/// This enables integration with the `ActionForm` component in `leptos_router`.
|
||||
pub fn url(&self) -> Option<String> {
|
||||
|
|
|
@ -155,7 +155,10 @@ where
|
|||
let on_form_data = Rc::new(move |form_data: &web_sys::FormData| {
|
||||
let data = action_input_from_form_data(form_data);
|
||||
match data {
|
||||
Ok(data) => input.set(Some(data)),
|
||||
Ok(data) => {
|
||||
input.set(Some(data));
|
||||
action.set_pending(true);
|
||||
}
|
||||
Err(e) => log::error!("{e}"),
|
||||
}
|
||||
});
|
||||
|
@ -179,6 +182,7 @@ where
|
|||
Err(e) => log::error!("{e:?}"),
|
||||
};
|
||||
input.set(None);
|
||||
action.set_pending(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue