I have an <abbr>
tag with class "timeago" in my HTML. When I set it value on page load, then call jQuery("abbr.timeago").timeago();
on document ready function it works.
My question is, what if I change abbr.timeago title dynamically from some javascript function, how can I make timeago plugin to do its magic on the updated abrr.timeago element?
Which function should I call? Should I remove jQuery("abbr.timeago").timeago();
from document ready function or leave it ? thank you
EDIT QUESTION:
@squiddy example works, updates the time only once and it just remains like that unchanged. For example if I put timeago to current time .. then it just stands like that it doesn't change?
BOUNTY UPDATE :
Please disregard previous question. In my website there is a link upon its click getJSON function is invoked which gets some information from server into a table.
Each row represents feedback from the server. Here is my getJSON pseudo code :
$.getJSON("feedback/" + feedbackId, function(data) {
var column ... declared variable in which column selector
.... some logic that populates table(irrelevant)
//Store last checked time in title
column.attr("title", iso8601(new Date()));
//invoke timeago on this title
column.html(jQuery.timeago(iso8601(new Date())));
....iso8601 is date format function
});
So this getJSON is invoked for every feedback I get from the server(n times). And when json completes the appropriate column in table is populated with last updated time.
But it seems that timeago is not reading the changed title value, it does not recognize updated DOM. I put a console.log(element.attr("title")) for each feedback from server for debugging purposes just to see if I set the title attribute to current time, and it does indeed but the timeago picks up the initially loaded title value.
What should I do I also tried this version :
$.getJSON("feedback/" + feedbackId, function(data) {
var column ... declared variable in which column selector
.... some logic that populates table(irrelevant)
//Store last checked time in title
column.attr("title", iso8601(new Date()));
//invoke timeago on this title
$(column).livequery(function() {
$(this).timeago(iso8601(new Date()));
console.log($(this).attr("title"));
});
});
I've spent few hours trying several possible solution .. like a function called every n seconds, to call the timeago function but always the same results