From c10ac658c7312996ba2a19cbcf0f969d4a182cb7 Mon Sep 17 00:00:00 2001 From: Nick Wientge Date: Tue, 3 Mar 2015 08:45:16 -0800 Subject: [PATCH] simplify current tab logic, don't use localstorage --- components/ionTab/ionTab.js | 16 ---------------- components/ionTabs/ionTabs.js | 19 +++++++------------ 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/components/ionTab/ionTab.js b/components/ionTab/ionTab.js index fffbb80..dec1dee 100644 --- a/components/ionTab/ionTab.js +++ b/components/ionTab/ionTab.js @@ -1,19 +1,3 @@ -Tracker.autorun(function () { - var ionTabCurrent = Session.get('ionTab.current'); - - if( ionTabCurrent ){ - localStorage.setItem('ionTab.current', ionTabCurrent); - } -}); - -Meteor.startup(function () { - var ionTabCurrent = localStorage.getItem('ionTab.current'); - - if( ionTabCurrent ){ - Session.set('ionTab.current', ionTabCurrent); - } -}); - Template.ionTab.events({ 'click': function (event, template) { if (template.data.path) { diff --git a/components/ionTabs/ionTabs.js b/components/ionTabs/ionTabs.js index f082140..70a05e9 100644 --- a/components/ionTabs/ionTabs.js +++ b/components/ionTabs/ionTabs.js @@ -9,18 +9,13 @@ Template.ionTabs.rendered = function () { Session.set('hasTabs', true); } - // This is a fallback if no localStorage is found: - // look through tabs and see if current route matches - // one of the href attributes, cross fingers - if( !Session.get('ionTab.current') ){ - this.$('.tabs').children().each(function() { - var href = $(this).attr('href'); - var current = Router.current().route.path(); - if(href === current){ - Session.set('ionTab.current', href); - } - }); - } + this.$('.tabs').children().each(function() { + var href = $(this).attr('href'); + var current = Router.current().location.get().path; + if(href === current){ + Session.set('ionTab.current', href); + } + }); }; Template.ionTabs.destroyed = function () {