Shawn
Shawn

Reputation: 23

Having an issue with jquery functions not working properly

I've been trying to get this little project I'm doing finished, but for some reason it is not properly working.

The issue is when I first visit the page and click the first link that appears in the main section it displays the popup box as wanted. Now when I click another day, for instance sunday and try to click the first link it doesn't do anything. And if I click back to Saturday the first link also doesn't do anything anymore.

It seems something is not properly activating or maybe a command is overwriting and not allowing it to work like it does when you first hit the landing page. I'm sorry if this is confusing but any help would be much appreciated.

The website is pouronline.com that's where i do all my testing.

Thank you

Upvotes: 2

Views: 118

Answers (2)

SeanCannon
SeanCannon

Reputation: 77966

Swap this:

$('a.poplight[href^=#]').click(function()

with this:

$('a.poplight[href^=#]').live('click',function()

You need to use a future-proof event observer because once you reload those anchors by changing the day in this case, the initial binding is lost. live() means to apply the binding to currently existing nodes as well as nodes that are added to the DOM at a later time.

Upvotes: 1

Brian Hoover
Brian Hoover

Reputation: 7991

You need to use the .live function.

So in your popup.js replace

 $('a.poplight[href^=#]').click(function() {

with

 $('a.poplight[href^=#]').live('click',function() {

Upvotes: 2

Related Questions