Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hitting back button of browser does not take you back to main site #60

Open
manrajgrover opened this issue Feb 12, 2016 · 14 comments
Open

Comments

@manrajgrover
Copy link
Member

Steps to reproduce this issue:

  1. Go to main page.
  2. Scroll down to "Past Events" and click "More Events".
  3. Hit back button of browser. You won't be redirected back to main page.
@handasolo
Copy link
Member

I don't think we'll be able to fix this without proper routing

@vipinkhushu
Copy link
Contributor

It might be happening because all events data are are being displaying dynamically by showing/hiding of divs using jquery on the same index.html page.

@vipinkhushu
Copy link
Contributor

Cant we have unique links for each event? @Slayslot @CuriousLearner

@handasolo
Copy link
Member

@vipinkhushu We do have unique links but they are just hashes. To get proper unique links I would recommend going for a proper routing library. Or, adding angular and implementing routing for now. We, already plan to go for angular on v2.
CC @CuriousLearner

@tarungarg546
Copy link

I dont know if you guys know or not there is onhashchange event handler present in JS .
So you can use it @vipinkhushu

@CuriousLearner
Copy link
Member

@tarungarg546 Why not issue a PR? :)

@vipinkhushu
Copy link
Contributor

Even i will see to it @tarungarg546 @CuriousLearner

@handasolo
Copy link
Member

@tarungarg546 How does that help this issue? I'm the one that created that onhashchange event handler.

@tarungarg546
Copy link

@Slayslot I presume you are just changing the hash when user clicks on more past events and when user clicks back button of browser then again hash gets changed so you can detect this hashchange and do whateva you may like then.
PS:- You have to avoid some gotchas like hash can be changed due to other reasons also..
There is SO thread for this :- http://stackoverflow.com/questions/25806608/how-to-detect-browser-back-button-event-cross-browser

@handasolo
Copy link
Member

Well, we don't have any written case for detecting when users clicks the back buttons and we also don't have a window.onhashchange event. This is what I've used to detect a hashchange.
if (hash.length > 0) { if (hash == "past-more" || hash == "future-more" || hash.match(/^event([0-9]+)$/)) { cardopen(hash); } }
You can find it on line 380 of script.js

@tarungarg546
Copy link

@Slayslot Could you provide me any documentation about how to run this website in my local env(i mean how to run your server ), So that before making an PR i could test this in my local env.

@handasolo
Copy link
Member

@tarungarg546 No local servers needed as of now, just fork, clone and you're good to go. Just beware of #56 if you work on chrome.

@tarungarg546
Copy link

@SlaySlot just few points ...

  • Your 2nd history api's pushState method is not called even once in this whole process[ line 394 in script.js ] so whatever you may be trying to achieve is not happening. Figure out why is it you will get to learn something cool. 🔑
  • Changing hash using window.location.hash does not cause any browser reload but it does creates an entry into browser history,so when back button is pressed it just changes location.hash so no reload here too. 😉

It will take sometime for me to fix this because of other urgent tasks.
Thanks 😄

@handasolo
Copy link
Member

Your 2nd history api's pushState method is not called even once in this whole process[ line 394 in script.js ] so whatever you may be trying to achieve is not happening. Figure out why is it you will get to learn something cool.

The only thing I learned here is that I'm a moron who can't remember to use the correct variables at the correct place. Thank for pointing that out anyway. In case, there was some other point you're trying to make here, do enlighten me.

Changing hash using window.location.hash does not cause any browser reload but it does creates an entry into browser history,so when back button is pressed it just changes location.hash so no reload here too. 😉

I'm indeed changing hash using window.location.hash, but in order to set it back to just www.mozpacers.org, when the back button is pressed, I have to use history api's pushState. If I use window.location.hash here we're left with www.mozpacers.org#, which,to be honest, is not very clean. And, using window.location will cause a reload.

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

No branches or pull requests

5 participants