From 0ca7242564aa1a2bdc1ab6891d46cae7d44dd889 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Mon, 17 Jun 2013 21:04:49 +0200 Subject: [PATCH] tabs view: Allowing for overriding tab content --- views/tabs/tabs.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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) { -- 2.20.1