mirror of
https://github.com/donl/meteor-ionic.git
synced 2026-05-29 06:12:31 -06:00
simplify current tab logic, don't use localstorage
This commit is contained in:
parent
9d945fe514
commit
c10ac658c7
2 changed files with 7 additions and 28 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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 () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue