performance: jquery.live() vs. creating specific listeners on demand?
Posted
by Haroldo
on Stack Overflow
See other posts from Stack Overflow
or by Haroldo
Published on 2010-04-02T09:46:48Z
Indexed on
2010/04/02
9:53 UTC
Read the original article
Hit count: 147
jQuery
I have a page with news item titles, clicking each one ajax loads a full news items including a photo thumbnail. I want to attach a lightbox to the thumbnails to show a bigger photo.
I have two options (i think):
- .live()
.
$('img .thumb').live('click', function())
- add a specific id based listener on callback of the news item click
.
$('div.news_item').click(function(){
var id = $(this).attr('id');
//click
show_news_item(),
//callback
function(){$(id+' .thumb').lightbox();}
})
© Stack Overflow or respective owner