JQuery TimeAgo Plugin - Setting Parameters

I am trying the "tweek" TimeAgo plugin so that I can remove the "back" suffix in each case.

Here is what I tried

$("time.timeago-nosuffix").timeago({suffixAgo: ""}); 

and

 $("time.timeago-nosuffix").timeago({ settings: { strings: { suffixAgo: null}} }); 

and

 $(document).ready(function () { $("time.timeago").timeago(); $("time.timeago-nosuffix").timeago(function () { suffixAgo: "" }); }); 

without any luck.

+4
source share
2 answers

Just set suffixAgo to an empty string

 $("time.timeago-nosuffix").timeago({strings: {suffixAgo: ""}}); 

UPDATE It seems that the current version of the plugin does not process runtime parameters. I created a git repository fork and created a version that does:

https://github.com/petersendidit/jquery-timeago/blob/master/jquery.timeago.js

+4
source

Disclaimer: I am the author of the time.

Unfortunately, as PetersenDidIt noted, timeago does not currently support runtime parameters. There was an open problem on GitHub, but I did not have time to look into it. PetersenDidIt, Thanks for the pull request. I'll see as soon as I can.

Meanwhile, there may be one of several possible workarounds ...

First set the suffix to the default empty string:

 $.timeago.settings.strings.suffixAgo = ""; 

Then run timeago as usual:

 $("time.timeago").timeago() 

Finally, instead of adding the "nosuffix" qualifier, add a class to each timestamp for which you want to get a suffix, and add a suffix to all of these timestamps once:

 $("time.timeago.suffix").after(" ago") 
+6
source

All Articles