How could I implement a fuzzy time date replacer using Knockout?
- by rball
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.