Skip to content

Instantly share code, notes, and snippets.

@Intrepidd
Created September 26, 2023 14:25
Show Gist options
  • Save Intrepidd/c8b7ede0c3628b7e8ad1fc9bdeccfd49 to your computer and use it in GitHub Desktop.
Save Intrepidd/c8b7ede0c3628b7e8ad1fc9bdeccfd49 to your computer and use it in GitHub Desktop.
Turbo stream action to update the navigator history
window.Turbo.StreamActions.advance_history = function () {
const url = new URL(this.getAttribute('url'))
window.Turbo.navigator.view.lastRenderedLocation = url
window.Turbo.navigator.history.push(url)
}
# frozen_string_literal: true
module TurboStreamAdditions
def advance_history(url)
turbo_stream_action_tag("advance_history", url: url)
end
end
Turbo::Streams::TagBuilder.prepend(TurboStreamAdditions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment