I'm trying to "tweek" the TimeAgo plugin so that I can remove the suffix "ago" on a case by case basis.
Here's what I've tried
$("time.timeago-nosuffix").timeago({suffixAgo: ""});
and
$("time.timeago-nosuffix").timeago({ settings: { strings: { suffixAgo: null}} });
as well as
$(document).ready(function () {
$("time.timeago").timeago();
$("time.timeago-nosuffix").timeago(function () {
suffixAgo: ""
});
});
with out any luck.
Disclaimer: I'm the author of timeago.
Unfortunately, as PetersenDidIt pointed out, timeago doesn't currently support runtime options. There's been an open issue on GitHub to address this, but I haven't had the time to look into it. PetersenDidIt, Thanks for the pull-request. I'll take a look as soon as I can.
Meanwhile, here's one of several possible workarounds...
First, set the suffix to an empty string by default:
$.timeago.settings.strings.suffixAgo = "";
Next, run timeago like you normally would:
$("time.timeago").timeago()
Lastly, instead of adding a "nosuffix" qualifier, add a class to each timestamp for which you want a suffix and add the suffix to all of those timestamps once:
$("time.timeago.suffix").after(" ago")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With