mirror of
https://github.com/scratchfoundation/jquery-timeago.git
synced 2024-11-27 01:35:40 -05:00
Add 'dispose' action
- use with elements about to be removed from the DOM or that otherwise no longer require updating - only clears interval; leaves node as-is - usage: $('.timeago').timeago('dispose');
This commit is contained in:
parent
49aeb6bf07
commit
3b895714a6
1 changed files with 7 additions and 1 deletions
|
@ -128,7 +128,7 @@
|
|||
refresh_el();
|
||||
var $s = $t.settings;
|
||||
if ($s.refreshMillis > 0) {
|
||||
setInterval(refresh_el, $s.refreshMillis);
|
||||
this._timeagoInterval = setInterval(refresh_el, $s.refreshMillis);
|
||||
}
|
||||
},
|
||||
update: function(time){
|
||||
|
@ -138,6 +138,12 @@
|
|||
updateFromDOM: function(){
|
||||
$(this).data('timeago', { datetime: $t.parse( $t.isTime(this) ? $(this).attr("datetime") : $(this).attr("title") ) });
|
||||
refresh.apply(this);
|
||||
},
|
||||
dispose: function () {
|
||||
if (this._timeagoInterval) {
|
||||
window.clearInterval(this._timeagoInterval);
|
||||
this._timeagoInterval = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue