On this page. You’ll be presented with a location to select. Select any one.
There is an e-blast popup that seems to repeatedly pop up on every page of the site (give it about five seconds). I only want it to pop up once per session. There is a cookie code to restrict the session, but I’m wondering with the new updated browsers that the code no longer works.
The e-blast is dependent upon the location chosen. Meaning, if you choose one location then there’s an e-blast for that particular location.
jQuery Cookie is being loaded, based upon the script source. Not sure if using localStorage would do any better.
I will assume by “e-blast” you mean the “Join our eclub” popup.
First of all, the site is belching 404’s. Couple of your image and CSS files are missing.
Second of all, the modal’s appearance is based on line 958 of your page. You seem to be invoking the modal with no discernible check on anything in the cookie that would indicate someone has already seen the modal. Perhaps a cookie-write when they close the modal?
As much as I appreciate your time in pointing that out, m_hutley, I was not given the opp to fix those right now. Just the one issue. If you’re able to assist me in understand why the cookie isn’t working, I would appreciate your time.
(Inline comments for my reading of the code.)
So the current code just says “If they’ve chosen a location, show them the eclub stuff when this function gets called.”
We want to remove that if they’ve already seen the modal. Well, we have to determine if they’ve seen the modal already. We’re already writing a cookie to their browser to store the location setting (which, incidentally, future feature to consider would be the ability to CHANGE the location)…
Cookies.set('location'), true);
(line 1246) [though that line has a typo in it now? Unexpected ) error]
[for the record, my line numberings are from the output, since i cant see your code, obviously]
modal.js is hiding how the close button works on your modal, but you can use jQuery to hunt it down and stick a click trigger on it (as well as the Submit buttons, because those count as closing the form as well)
and then inside the if block above, instead of nakedly calling the show modal check to see if ‘shownclub’ is true (or more likely, if it’s NOT true, show the modal).
Well I wish I was able to see what you were seeing, since our output of row numbers is different, and I get a little lost in your translation.
Basically you’re telling me that the location cookie is there but the ability to disable the modal upon ‘close’ or upon the user already visiting the site, correct? And then the only way of knowing is to modify the ‘close’ trigger button? With that, also add a check if the ‘shownclub’ (don’t know where you go this term) is set to ‘false’ then show the modal, yes?
Clarify if I’m wrong.
I’m not all too familiar with the coding of jQuery, but I am gaining a better understanding of your inline comments regarding how this was structured.
Correct.
The cookie is being set to define the location. So SOMEWHERE in your code, you’ve got that set up. I don’t actually think it’s setCookie, because that function isnt in scope for me by the time the page loads. Somewhere, you’ve told the site ‘make a cookie with location set to whatever button they pushed.’
So what we need to do is not -change- the behavior of the close (and submit) buttons of the ‘join the eclub’ modal (because we still want them to do their thing), but instead tack a little extra code onto them that says 'When they push one of these things, stick another cookie into the browser, that says they’ve seen the modal [they’ve either closed it uninterested, or filled out the form and hit the submit button].
Then, when the page gets reloaded, we check to see if they’ve seen the modal by seeing if the cookie is there. If they have, we dont show it again.
Ah there we go.
So, lets use that same code in this instance.
In between these two lines:
},10000);
$(".grand-junction").click(function(){
stick this:
$("#myModal1 button").on('click',function() {
var now = new Date();
var time = now.getTime();
time += 30*24*60*60*1000;
now.setTime(time);
document.cookie =
'shownmodal=true' +
'; expires=' + now.toUTCString() +
'; path=/';
});
Okay. Experiencing the Join the Club isn’t even popping up for the first time. I checked with a variety of browsers, cleared the caches. After I select the location, no pop up to join the club.