You can bind it to ajaxComplete
event, like this:
$(document).on('ajaxComplete', function(){
do_timeago();
});
BTW, I didn't understand your timeout in do_timeago
function. Also, JS best practices are a bit different than ruby ones, consider rename your function to something like doTimeago
.
Hope it helps.