Skip to content

Instantly share code, notes, and snippets.

Created May 23, 2019 15:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Update URL via Liveview
# In somethingLive.ex:
def handle_event("some_event", _params, socket) do
assign(socket, :updated_url, Routes.project_path(MyApp.Endpoint, :index))
# In template: <%= js_url_update_script(assigns[:updated_url]) %>
# In form_helpers.ex, or similar:
def js_url_update_script(updated_url) do
if updated_url do
raw("window.history.replaceState(null, null,'#{updated_url}')")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment