开发者

jQuery events within dynamic content via ajax

Is there a way I can load content dynamically using ajax and retain any jquery functionality that the loaded content may have?

For example, I'd like to load in a Twitter like feed of DB records. Each record can be voted thumbs up or thumbs down. The voting uses some AJAX and I can't retain event functionality when loaded into a parent page.

ok forgive such a noob question but I'm lost with the example on the jquery page. When it says:

$('a').cl开发者_如何学JAVAick(fn); 
$('#mydiv').load('my.html',function(){ 
$('a').click(fn); });

what is fn supposed to represent?


Use event delegation, .live() or .delegate() will do the trick. It has a lot more advantages than just retaining functionality too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜