How to jQuery delegate with out event type?
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();
});
精彩评论