I am using Turbolinks but I would like to take over history management for one piece of my application's flow. Specifically:
- User loads product page
- User clicks on product and product modal appears (without reloading the page)
- Upon loading the product model the URL updates to the loaded product's URL
- User clicks "back"
- The model disappears and the user returns to the product page but the product page doesn't reload
If I manually history.pushState(null, null, PRODUCT_URL) after the user clicks in step (2) then everything works except step (5) during which Turbolinks reloads the entire product page.
Ideally I could hook into the window's popstate event and cancel Turbolink's ajax request, but per Turbolinks docs "Restoration visits cannot be canceled and do not fire turbolinks:before-visit"