can3p/iviewer — Issue #20: How do I add 1 to the value of iviewer 'src' to create gallery navigation?
Author: shngrdnr
Created: 2012-02-19 12:15:27+00:00
State: open

I'm using iviewer for an online image gallery.

I was previously using the code below for a 'next' button to cycle through the images in the gallery (which are all named 001.jpg, 002.jpg, 003.jpg and so on):

```var i = 1;
$("#next").click(function(){
i++;
iv1.iviewer('loadImage', "/folder/" + ("00" + i).slice(-3) + ".jpg");
return false;
});```

However, the problem is that elsewhere on the same page I'm using some jquery code to change the displayed image in the iviewer on the basis of the class attribute of the relevant links (which are numbered similarly to the images - chimg001, chimg002 and so on):

```$("ul.imageThumbs > li > a").click(function(){
var k = $(this).attr("class");
iv1.iviewer('loadImage', "/folder/" + ((k).slice(-3)) + ".jpg");
return false;
});```

When I use this code to change the image and then try to cycle through using the 'next' button, the 'next' function doesn't refer to the new image source, but only the initial image source of the iviewer.

Is there any way of changing the image src in iviewer by adding or substracting 1 to the current image src name?