timeago-koext.js 611 B

1234567891011121314
  1. ko.bindingHandlers.timeago = {
  2. init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
  3. var value = valueAccessor();
  4. var valueUnwrapped = ko.unwrap(value);
  5. element.title = moment(valueUnwrapped).toISOString();
  6. $(element).timeago();
  7. },
  8. update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
  9. var value = valueAccessor();
  10. var valueUnwrapped = ko.unwrap(value);
  11. element.title = moment(valueUnwrapped).toISOString();
  12. $(element).timeago('update', element.title);
  13. }
  14. }