Skip to content
This repository has been archived by the owner on Jul 28, 2018. It is now read-only.

Add option to skip pushState during Turbolinks.visit with new history option #652

Open
rmm5t opened this issue Jan 5, 2016 · 1 comment

Comments

@rmm5t
Copy link

rmm5t commented Jan 5, 2016

I'd like to open up a discussion about the possibility of adding an option to Turbolinks.visit to allow for skipping any pushState changes during that particular request.

There are some cases where I'd like to use Turbolinks to load a new partial using a different URL resource than the current page, but after replacing the partial, I'd like to avoid changing the address bar, and more importantly, not change the browsers history for that request. There's also an alternative case where instead of just skipping the pushState call, I might prefer to issue a replaceState call for that particular Turbolinks.visit request.

If this is something that has a potential for being pulled in, I'm willing to investigate and work on a pull-request, but I wanted to get buy-in first.

Potential option name:

  • history (defaults to "pushState" or true; other valid values, "replaceState" or false)

Example usage:

// Refresh the comments without changing the URL nor browser history
Turbolinks.visit(url, { change: ['comments'], history: false });

// Refresh the comments, change the address bar, but don't create a new browser history entry
Turbolinks.visit(url, { change: ['comments'], history: 'replaceState' });

// Good ol' regular usage. All being equal:
Turbolinks.visit(url, { change: ['comments'] });
Turbolinks.visit(url, { change: ['comments'], history: true });
Turbolinks.visit(url, { change: ['comments'], history: 'pushState' });
@rmm5t
Copy link
Author

rmm5t commented Jan 5, 2016

Looks like Turbolinks 5 implements this with an action option. For example:

Turbolinks.visit(url, { action: "replace" });

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant