Parcourir la source

feat: Adding an event to go back just as the user would. (#3636)

* feat: Adding an event to go back just as the user would.

* fix: Simplification suggested by masenf.

* fix: And now apply the fix to the right function.
abulvenz il y a 10 mois
Parent
commit
5071245127
1 fichiers modifiés avec 9 ajouts et 0 suppressions
  1. 9 0
      reflex/event.py

+ 9 - 0
reflex/event.py

@@ -509,6 +509,15 @@ def console_log(message: str | Var[str]) -> EventSpec:
     return server_side("_console", get_fn_signature(console_log), message=message)
 
 
+def back() -> EventSpec:
+    """Do a history.back on the browser.
+
+    Returns:
+        An event to go back one page.
+    """
+    return call_script("window.history.back()")
+
+
 def window_alert(message: str | Var[str]) -> EventSpec:
     """Create a window alert on the browser.