Skip to content
scalive
Menu
ConnectingLiveReconnectingOffline
GitHub
o

navigation

object navigation

Helpers that ask the visitor to confirm before leaving a page with unsaved changes. See navigation guards.

Defined by scalive.navigation. View source (scalive/api/src/scalive/Scalive.scala:292-308)

Methods1

guardWhen

def guardWhen(dirty: Signal[Boolean], message: String): Mod.Attr[Nothing]

Guards browser-initiated navigation while dirty is true.

Add the returned modifier to the element which owns the dirty state and install the NavigationGuardAssets script in the root layout. The browser runtime uses message for live links, live patch links, and LiveView history traversal. Browsers use their own generic message for cross-document history traversal, reload, and tab-close confirmation.

The guard reflects the latest value rendered by the server. Server-issued navigation and navigation encoded in a JSCommand bypass the configured confirmation, but a resulting document unload may still request the browser's generic confirmation.

Defined by scalive.navigation.guardWhen. View source (scalive/api/src/scalive/Scalive.scala:306-308)