Page 1 of 1

Prevent Default Action

Posted: Mon May 09, 2011 7:52 pm
by unemployment
I am loading a link with ajax. When the link pops on the screen and I click it, I get redirected to my 404 page and my lightbox doesn't load.

If the link pops in and I refresh my browser, then I click the link my lightbox will show up.

How can I do a prevent default on the <a href> in pure JS? No frameworks please.

Re: Prevent Default

Posted: Mon May 09, 2011 8:28 pm
by jacek
unemployment wrote:in pure JS? No frameworks please.
:D :D :D :D

You need to have the function that does the lightbox or what ever it is that happens when you click the link return false. that should stop the default action.

Re: Prevent Default Action

Posted: Tue May 10, 2011 5:19 pm
by unemployment
Fixed. As it turns out... it wasn't even a return false issue. JavaScript can be very tricky sometimes.

Re: Prevent Default Action

Posted: Tue May 10, 2011 6:25 pm
by jacek
what did you do ?

Re: Prevent Default Action

Posted: Tue May 10, 2011 7:33 pm
by unemployment
jacek wrote:what did you do ?
I wasn't calling the light box. The Ajax was pulling in a dead link and the JavaScript referenced the hard coded HTML link so when the Ajax overrode the hard coded link that JavaScript wasn't referencing the Ajax link. It was basically due to not properly calling the light box in the Ajax request.

Re: Prevent Default Action

Posted: Tue May 10, 2011 7:36 pm
by jacek
hmm, fair enough ;)

As long as its working eh :D