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.
Prevent Default Action
Re: Prevent Default
unemployment wrote:in pure JS? No frameworks please.
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
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.
-
- Posts: 165
- Joined: Fri May 06, 2011 5:02 pm
Re: Prevent Default Action
Fixed. As it turns out... it wasn't even a return false issue. JavaScript can be very tricky sometimes.
-
- Posts: 165
- Joined: Fri May 06, 2011 5:02 pm
Re: Prevent Default Action
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.