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' });
I'd like to open up a discussion about the possibility of adding an option to
Turbolinks.visit
to allow for skipping anypushState
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 areplaceState
call for that particularTurbolinks.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"
ortrue
; other valid values,"replaceState"
orfalse
)Example usage: