mirror of
https://github.com/scratchfoundation/jquery-timeago.git
synced 2024-11-23 15:57:54 -05:00
15 lines
611 B
JavaScript
15 lines
611 B
JavaScript
|
ko.bindingHandlers.timeago = {
|
||
|
init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
|
||
|
var value = valueAccessor();
|
||
|
var valueUnwrapped = ko.unwrap(value);
|
||
|
element.title = moment(valueUnwrapped).toISOString();
|
||
|
$(element).timeago();
|
||
|
},
|
||
|
update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
|
||
|
var value = valueAccessor();
|
||
|
var valueUnwrapped = ko.unwrap(value);
|
||
|
element.title = moment(valueUnwrapped).toISOString();
|
||
|
$(element).timeago('update', element.title);
|
||
|
}
|
||
|
}
|