I'm having a small issue creating objects out of list items in an unordered list. I'm creating a gallery and I need for each gallery thumbnail to be it's own object, so I'm iterating through each list item using jQuery's $.each()
The problem is I don't know how to give each object/li it's own instance name.
Here's the code:
function galleryButton(){
this.link
this.name
this.image
this.identifier,
this.goPage = function(){
$('.container').animate({opacity : '0'}, 500).load(this.link + ' .galContainer', function(){$('.container').animate({opacity : '1'})});
return false;
}
}
$(document).ready(function(){
$.ajaxSetup({
cache:false
});
$('.gallery li a').each(function(node, value){
this = new galleryButton();
this.link = $(this).attr('href');
this.name = $(this).attr('name');
this.image = $(this + " img").attr('src');
this.identifier = $(this).attr('data-pic-id');
$(this).click(this.goPage);
})
$('.goback').click(function(){
var back = $(this).attr('href');
$('.container').animate({opacity : '0'}, 500).load(back + ' .gallery', function(){$('.container').animate({opacity : '1'})});
return false;
});
});
thiskeyword!!!