From 009dbb9523ed4b7b558108f204cc43c7ffa0408c Mon Sep 17 00:00:00 2001 From: vogdb Date: Wed, 18 Mar 2015 19:57:31 +0300 Subject: [PATCH] Add teardown method to js views. --- library/CM/App.js | 8 ++++++++ library/CM/Component/Abstract.js | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/library/CM/App.js b/library/CM/App.js index 0c9aff0e0..ed13d45b6 100644 --- a/library/CM/App.js +++ b/library/CM/App.js @@ -310,6 +310,14 @@ var CM_App = CM_Class_Abstract.extend({ $dom.find('.openx-ad:visible').openx(); $dom.find('.fancySelect').fancySelect(); }, + /** + * @param {jQuery} $dom + */ + teardown: function($dom) { + $dom.find('.timeago').timeago('dispose'); + $dom.find('textarea.autosize, .autosize textarea').trigger('autosize.destroy'); + $dom.find('.showTooltip[title]').tooltip('destroy'); + }, /** * @param {jQuery} $element * @param {Function} [success] fn(MediaElement, Element) diff --git a/library/CM/Component/Abstract.js b/library/CM/Component/Abstract.js index 153b13912..986d1c1ae 100755 --- a/library/CM/Component/Abstract.js +++ b/library/CM/Component/Abstract.js @@ -9,6 +9,10 @@ var CM_Component_Abstract = CM_View_Abstract.extend({ CM_View_Abstract.prototype._ready.call(this); cm.dom.setup(this.$()); + + this.on('destruct', function() { + cm.dom.teardown(this.$()); + }) }, /**