Monday, 20 August 2018

Choice / Session storage update

Tim got back to me on the issue with my code (here) - the main issues were I had a typo where I wrote questB twice, and that session storage apparently stores booleans as strings, so my "true" 's should be " 'true' " in my if statement. I also need to call the if statement again with each click. I had actually tried that last part, but because of the former issues it wouldn't work.

He made this codepen as an example, a fixed version of mine.

-------
Now to try to get that to work on multiple pages:

I was having issues with either the continue button (which should not show up until you've linked to all three pages) showing up at the beginning anyway - I tried to fix this by changing the original css to display:none, but that mean't it wouldn't show up afterwards because I guess the css overrides the javascript.

I put in the console.log part (at the bottom) to check if the values were being assigned properly.

I then realised that when you travel back to the page after clicking on all three links it doesn't actually check the if statement on its' own -  it's only when you click, now. So I added checkQuests() at the bottom so it also does that when you travel to the page.

Tim briefly suggested in his email to maybe do the checks, not on the clicks, but when you travel to the other page - which I might experiment with later, I'll see. It might end up being more efficient code that way.

I actually realised after this that I don't even need checkQuests() to be under the clicks as well as just as itself, so that helps.




No comments:

Post a Comment