From c87d8db8cca1ecbd5e870363c735eb7e2ab61dbc Mon Sep 17 00:00:00 2001 From: Andrew Redden Date: Sun, 3 May 2020 18:23:23 -0300 Subject: [PATCH] Handler for Window Popstate --- app/assets/v2/js/pages/dashboard-hackathon.js | 12 ++++++------ app/assets/v2/js/pages/profile-tribes.js | 7 ++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/assets/v2/js/pages/dashboard-hackathon.js b/app/assets/v2/js/pages/dashboard-hackathon.js index b4e55fdc430..87de8c8a536 100644 --- a/app/assets/v2/js/pages/dashboard-hackathon.js +++ b/app/assets/v2/js/pages/dashboard-hackathon.js @@ -877,6 +877,12 @@ refreshBounties(null, 0, false); initDOM(); addPopover(); + $(window).on('popstate', function(e) { + e.preventDefault(); + // we change the url with the panels to ensure if you refresh or get linked here you're being shown what you want + // this is so that we go back to where we got sent here from, townsquare, etc. + window.location = document.referrer; + }); }, 0); }, methods: { @@ -908,12 +914,6 @@ history.pushState({}, `${vm.hackathonObj['slug']} - ${newPathName}`, newUrl); - $(window).on('popstate', function(e) { - e.preventDefault(); - // we change the url with the panels to ensure if you refresh or get linked here you're being shown what you want - // this is so that we go back to where we got sent here from, townsquare, etc. - window.location = document.referrer; - }); } }, data: () => ({ diff --git a/app/assets/v2/js/pages/profile-tribes.js b/app/assets/v2/js/pages/profile-tribes.js index 5c54f24b932..88505ce2548 100644 --- a/app/assets/v2/js/pages/profile-tribes.js +++ b/app/assets/v2/js/pages/profile-tribes.js @@ -226,7 +226,12 @@ const loadDynamicScript = (callback, url, id) => { } }, mounted() { - console.log('we mounted'); + $(window).on('popstate', function(e) { + e.preventDefault(); + // we change the url with the panels to ensure if you refresh or get linked here you're being shown what you want + // this is so that we go back to where we got sent here from, townsquare, etc. + window.location = document.referrer; + }); let vm = this; vm.isLoading = false;