simplify current tab logic, don't use localstorage

This commit is contained in:
Nick Wientge 2015-03-03 08:45:16 -08:00
parent 9d945fe514
commit c10ac658c7
2 changed files with 7 additions and 28 deletions

View file

@ -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) {

View file

@ -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 () {