hi i've got a script like this :
jQuery(window).ready(function($) {
$.fn.prettyPhoto();
$.get("xml/kategoria1.xml",{},function(xml){
$('image',xml).each(function(i) {
lightbox = $(this).find("lightbox").text();
openLightbox(lightbox)
});
});
});
function openLightbox(path) {
$.prettyPhoto.open(path);
And it opens only a single image from xml, i want to open all images from xml called lightbox.
here is my XML file :
<?xml version="1.0" encoding="utf-8"?>
<images>
<image source="Zdjecia/Galeria/Kategoria1/Miniaturki/image1.jpg" lightbox="Zdjecia/Galeria/Kategoria1/Duze/image1.jpg">
<lightbox>Zdjecia/Galeria/Kategoria1/Duze/image1.jpg</lightbox>
</image>
<image source="Zdjecia/Galeria/Kategoria1/Miniaturki/image2.jpg" lightbox="Zdjecia/Galeria/Kategoria1/Duze/image2.jpg">
<lightbox>Zdjecia/Galeria/Kategoria1/Duze/image2.jpg</lightbox>
</image>
<image source="Zdjecia/Galeria/Kategoria1/Miniaturki/image3.jpg" lightbox="Zdjecia/Galeria/Kategoria1/Duze/image3.jpg">
<lightbox>Zdjecia/Galeria/Kategoria1/Duze/image3.jpg</lightbox>
</image>
</images>
Please for help.
Greetings Krystian
The problem is that in your code, you will open a lightbox for each image.
What you should do is creating an array containing all the images, and then pass it to the lightbox.
Instead of this:
$('image',xml).each(function(i) {
lightbox = $(this).find("lightbox").text();
openLightbox(lightbox)
});
Do this:
images = new Array();
$('image',xml).each(function(i) {
image = $(this).find("lightbox").text();
images.push(image);
});
openLightbox(images)