So I have this program that’s supposed to keep track of and react to events in a website, and the counter works fine and all that, but for some reason my events counter doesn’t react to an event change. So, I have my eventsCounter set to 1 and it’s supposed to do it’s own little song and dance so to speak and you double click the thingy and it’s supposed to tick the eventsCounter up by one so something different can do it’s thing. But the thing is, the website just acts like eventsCounter is still 1 instead of 2, so it’s doing a little song and dance that shouldn’t be happening. I check the console and it says eventsCounter = 2 even though it’s acting like eventsCounter = 1. And I’m like … what?! Okay… must be an issue with how I’m doing it so I refresh the page and lo and behold! It’s doing what it’s supposed to with an eventCounter of 2. Please help!!
let eventsCount = parseInt(localStorage.getItem('eventsCount')) || 1;
localStorage.setItem('eventsCount', eventsCount);
if (eventsCount === 1) {
$("#selection").click(
function() {
// blah blah blah, you get it...
});
$("#selection").dblclick(function() {
localStorage.setItem('eventsCount', 2);
});
if (eventsCount === 2) {
if (hasManual) {
clearTimeout(timeoutId);
if (hovered) {
$("#popUp").removeClass("pop-in").addClass("pop-out");
setTimeout(function() {
$("#popUp").removeClass("pop-out");
}, 490); // more junk
}
messageDelay = 3000;
popUpClass("+1 User Manual");
localStorage.setItem('hasManual', true);
}
}
I checked the Applications tab thing in the Developers Tools menu thingy and it said it stored 2 in its local storage even thought it was acting like 1 was in it’s local storage.
I tried triggering a reflow with this line of code:
void $("#popUp")[0].offsetWidth;
NOTHING!
All my jQuery works just fine except for this bit. I’ve tried a lot. My goal was to get it to update on its own but it needs a refresh for some godforsaken reason.
I tried turning over every stone I could think of, trust me. I’m pretty new to this stuff so please go easy. I made this account like 20 minutes ago just to ask this question. Please help.
user24893579 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.