From: Aleksander Ɓukasz Date: Mon, 17 Jun 2013 19:04:49 +0000 (+0200) Subject: tabs view: Allowing for overriding tab content X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/0ca7242564aa1a2bdc1ab6891d46cae7d44dd889?ds=sidebyside tabs view: Allowing for overriding tab content --- diff --git a/views/tabs/tabs.js b/views/tabs/tabs.js index 43df1c1..7c94938 100644 --- a/views/tabs/tabs.js +++ b/views/tabs/tabs.js @@ -39,14 +39,16 @@ define([ }, addTab: function(title, slug, content) { - if(this.contents[slug]) - return false; + if(this.contents[slug]) { + this.contents[slug].detach(); + } this.contents[slug] = content; var text = (typeof title === 'string') ? title : (title.text || ''); var icon = title.icon || null; - this.nodes.tabBar.append(this.handleTemplate({text: text, icon: icon, slug: slug})); + if(!this.tabExists(slug)) + this.nodes.tabBar.append(this.handleTemplate({text: text, icon: icon, slug: slug})); if(!this.selectedTab) this.selectTab(slug); }, @@ -75,6 +77,10 @@ define([ return this.selectedTab; }, + tabExists: function(slug) { + return this.nodes.tabBar.find('a[href="#'+ slug + '"]').length > 0; + }, + /* Events */ _onTabTitleClicked: function(e) {