开发者

How to jQuery delegate with out event type?

开发者 https://www.devze.com 2023-03-26 10:17 出处:网络
I have a facebook like feeds application. I would like to execute timeago plugin for each of the feed that gets added dynamically.

I have a facebook like feeds application. I would like to execute timeago plugin for each of the feed that gets added dynamically.

$("abbr.timeago").timeago()

How do I call jQuery delegate to execute timeago() f开发者_JAVA百科or each of the feed/new feed added dynamically?

i.e, What would be the event type on delegate method? or how to delegate with out event type?

Thanks in advance.


.delegate() works for events only. If your plugin has a custom event (which is possible) you can delegate to that. If not, you can try extending it yourself to have such an event.

EDIT: I misunderstood your question. You can indeed fire a custom event, and delegate to that: See the last example seen on http://api.jquery.com/delegate/


Well i don't think you can delegate it, the only thing i think you could do is call the plugin each time a feed is added. Just put the call

 $("abbr.timeago").timeago()

after the feed is added to the DOM


try http://api.jquery.com/live/

$('abbr.timeago').live('load', function(){
    $(this).timeago();
});
0

精彩评论

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