Reputation: 755
First my code:
Html
<div class="product_image m2" id="m2"><a href="#" id="10" class='multi2'>test..</a></div>
JS
$(document).ready(function(){
$("#m2 a").bind("click", function() {
var value = $( this ).attr( 'id' );
alert(value);
return false;
});
if ($(".multi2").length > 0){
$(".multi2").yoxview({
cacheImagesInBackground:true,
skin: "top_menu",
lang: "hu",
images: [
{ media: { src: 'images/galeria/cella/image01'+value+'.JPG', title: 'Cella hegesztő' }},
{ media: { src: 'images/galeria/cella/image015.JPG', title: 'Cella hegesztő' }},
{ media: { src: 'images/galeria/cella/image013.JPG', title: 'Cella hegesztő' }},
]
});
}
});
So, I use Yoxview. Multi2 class define the images and when user click on link (or thumbnail). lightbox shown and slideshow start.
The slideshow start every time from the first image defined in JS. I would like to change this so i would like to pass the id of href inside in m2 div to the image list.
Unfortunately I can't do this. I try this code but with this the script crash. How can I pass VALUE to image list?
Upvotes: 2
Views: 156
Reputation:
Try code below, this probably will work, but not a good solution.
EDIT
By the way as Kanishka mentioned its not legal to start ID with a number. You can store photo id as an custom attribute <a href="#"... data-photoid="2" ... />
and get it using jquery data() $(this).data('photoid')
.
$(document).ready(function(){
$("#m2 a").bind("click", function() {
var value = $( this ).attr( 'id' );
if(!$(this).data('yoxed')) {
$(this).yoxview({
cacheImagesInBackground:true,
skin: "top_menu",
lang: "hu",
images: [
{ media: { src: 'images/galeria/cella/image01'+value+'.JPG', title: 'Cella hegeszto' }},
{ media: { src: 'images/galeria/cella/image015.JPG', title: 'Cella hegeszto' }},
{ media: { src: 'images/galeria/cella/image013.JPG', title: 'Cella hegeszto' }}
]
});
$(this).data('yoxed', true).trigger('click');
}
}
return false;
});
});
Upvotes: 2