From: Aleksander Ɓukasz Date: Tue, 18 Jun 2013 10:25:00 +0000 (+0200) Subject: Layout and tabs view informs its views about being hidden X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/103c278d4f2eae78854cbfcfc0a25f2a0b1c4c47 Layout and tabs view informs its views about being hidden --- diff --git a/fnpjs/layout.js b/fnpjs/layout.js index 99b2e58..5fe61cc 100644 --- a/fnpjs/layout.js +++ b/fnpjs/layout.js @@ -12,6 +12,12 @@ define(['libs/jquery-1.9.1.min', 'libs/underscore-min'], function($ ,_) { view.onShow(); }); }; + this.dom.onHide = function() { + _.values(layout.views).forEach(function(view) { + if(view.onHide) + view.onHide(); + }); + }; }; diff --git a/views/tabs/tabs.js b/views/tabs/tabs.js index 7298d4e..bc14083 100644 --- a/views/tabs/tabs.js +++ b/views/tabs/tabs.js @@ -57,8 +57,12 @@ define([ if(slug !== this.selectedTab && this.contents[slug]) { this.trigger('leaving', this.selectedTab); - if(this.selectedTab) - this.contents[this.selectedTab].detach(); + if(this.selectedTab) { + var toDetach = this.contents[this.selectedTab]; + if(toDetach.onHide) + toDetach.onHide(); + toDetach.detach(); + } this.nodes.content.append(this.contents[slug]); if(this.contents[slug].onShow) { this.contents[slug].onShow();