views:

294

answers:

2

I have a code that replaces href's using Jquery, .attr({ href : newpath }); and I am using Shadowbox. After changing the href and loading shadowbox, the shadowbox loads the old href instead of the new one.

For example :

<a id ="shadowboxlink" href="images/firstimage.jpg" rel="shadowbox">shadowbox link</a>

then the jquery would be something like this :

$("#shadowboxlink").attr({href : newpath}); //whereas var newpath is a string like "images/secondimage.jpg"

so then after jquery is executed, the shadowbowlink has the correct href of images/secondimage.jpg, but when you load it, the shadowbox loads the firstimage.jpg

Anyone have any insight? Thanks! =) Ken

A: 

Just by looking at the information provided on the shadowBox website, it sounds like what you want to do is just add a second <a> in your markup.

<a id ="shadowboxlink" href="images/firstimage.jpg" rel="shadowbox[gallery]">shadowbox link</a>
<a id ="shadowboxlink" href="images/second.jpg" rel="shadowbox[gallery]">shadowbox link</a>

And make sure you add the [gallery] (or whatever you want to call it) to associate those two images with each other.

If that's not what you're looking to do, try running the Shadowbox.init(); code again after changing the href.

idrumgood
sorry, i don't really understand what you meant by "adding a second <a> in my markup"the shadowbox.init() didnt' work =/ , the shadowbox is still loading the first href and not the second href
Ken
A: 

The solution is to use "Shadowbox.setup" and reload it whenever you click something.

Thanks everyone.

Ken