Prevent live navigation

Is there an existing method available to prevent live navigation? For example, when a form has changes {!Enum.empty?(@changeset.changes) via some data-confirm attribute message.

I have seen this hook example, however that only works when the window is unloaded.

The only method I can think of is broadcasting a message to my root live_view and using a Surface Context to add a data-confirm to all my live redirects links.

Can you add a CSS class to the links which disables the a tags when that condition is true?

I mention a method in this short guide on making a multi-step form in LV.

Not sure if that’s what you had in mind, but it works for preventing stepping forward. Perhaps similar approach might work? Hope it helps :heart:

Edit: I just reread your post: sorry I’m fried and totally missed the gist of your question. You can disregard this. :blush:

Thanks for the reply @cmo, I’m wondering more if there’s an existing API or a trick to intercept routing. Disabling links isn’t great for accessibility - I’d prefer the window.confirm method.

@f0rest8 Thanks for sharing your article. Yes, looks like it solves a different problem :slight_smile:

1 Like