I've noticed in my vue/laravel project that if I press the back button on the browser it doesn't repopulate my data. What is the simplest way/most browser compatible to watch for a browser back button and run an axios to fetch the latest data?
I tried adding this but from what I can see document.addEventListener("backbutton" only works on devices?
When I press back it doesn't fire the method.
@fylzero That doesn't seem to work sadly. I am thinking the only way to deal with this is just to do an axios get everytime the page loads instead of trying to bind the data through laravel.
I generally only would use JavaScript for small enhancements.
General if a page is not loaded with all kinds of unnecessary things a normal page load is just fine.
But when you see left menus right menus top navs all over the place most Pages do not need all that stuff, they just need a link back to the main nav page.
If you use html5 routing with vue-router, back button support is automatic ... beyond that -- please don't hijack the default behavior of the back button, it's endlessly frustrating for the user for things to not behave normally.
@chrisgrim That might be the only real acceptable reason to interrupt normal navigation, so long as it's not something you do everywhere ... carry on :)
Actually I decided to just rewrite all my code and instead of using a prop to bind the data I am using a mounted() axios get request. Not as clean looking but it always gets the latest data even if the user presses the back button.