Skip to content

Instantly share code, notes, and snippets.

@fguillen
Created December 18, 2009 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fguillen/259820 to your computer and use it in GitHub Desktop.
Save fguillen/259820 to your computer and use it in GitHub Desktop.
$('.lazy_loading').each(function() {
if( !this.complete ){
var image = $(this);
var image_original_src = $(this).attr('src');
image.attr({src: '/images/item_image_loading.gif'});
(function() { // New scope hack
var _image = image;
$(new Image())
.load( function(){
$(this).hide();
_image.attr({src: $(this).attr('src')});
})
.attr({src: image_original_src});
})(); // Execute immediately
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment