views:

28

answers:

1

Using pageless1 to trigger an ajax load of older, timestamped content onto the end of the page, I need .timeago() to act upon those newly loaded dates. It works on the content loaded the first time you arrive at the page, but not the content loaded via Ajax later.

Thanks!

+3  A: 

For running plugins (things not event handler based) you can still use the .livequery() plugin, like this:

$('.selector').livequery(function() {
  $(this).timeago();
});

If it's an event handler, .live() or .delegate() works, or if it's a plugin you can also run the plugins on loaded content, for example:

$.ajax({
  //options...
  success: function(data) {
    //do stuff
    $('.selector', data).timeago();
  }
});

This runs the plugin on that selector, but only for elements that came back in that AJAX response, by using the context argument of $(selector, [context]).

Nick Craver
Thanks, Nick! I will try this tomorrow…
Alfonso