How could I implement a fuzzy time date replacer using Knockout?
Posted
by
rball
on Stack Overflow
See other posts from Stack Overflow
or by rball
Published on 2012-06-29T21:09:58Z
Indexed on
2012/06/29
21:16 UTC
Read the original article
Hit count: 206
I'd like to implement what this plugin does using jQuery: https://github.com/rmm5t/jquery-timeago
A short description of that plugin:
This will turn all abbr elements with a class of timeago and an ISO 8601 timestamp in the title (conforming to the datetime design pattern microformat):
<abbr class="timeago" title="2011-12-17T09:24:17Z">December 17, 2011</abbr>
Into something like this:
<abbr class="timeago" title="December 17, 2011">about 1 day ago</abbr>
Except using knockout my markup looks like this:
<abbr data-bind="attr: { title: Posted }" class="timeago"></abbr>
I think something isn't synced up because nothing is happening even if I put the call to timeago within the viewmodel itself. I'm guessing I need a subscriber that's attached to the observable "Posted" but I'm not sure how to set that up.
© Stack Overflow or respective owner