Refer to Object's property inside $.each()
-
function JGallery(){
this.name="defaultGallery";
this.images=[{//some JSON here}]
this.render=function(){
$.each(this.images, function(imageIndex,image){
//i want append div with id of the name property of jgallery class
$("<div></div>").appendTo("#container").attr("id",this.name);
);
}
I've tried to debug it in firebug, but I guess there is a problem with the scope of the 'this'. The 'this' in
-
//i want append div with id of the name property of jgallery class
$("<div></div>").appendTo("#container").attr("id",this.name);
seems to refer to the iterator in the $.each().
I've tried to do this.this.name but it still doesn't work. Is there any way to allow me access the property of the Jgallery class?