ZippyMind
ZippyMind

Reputation: 141

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() for 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.

Upvotes: 3

Views: 571

Answers (3)

Jacek Kaniuk
Jacek Kaniuk

Reputation: 5229

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

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

Upvotes: 0

Nicola Peluchetti
Nicola Peluchetti

Reputation: 76910

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

Upvotes: 0

Madara's Ghost
Madara's Ghost

Reputation: 175098

.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/

Upvotes: 1

Related Questions