mirror of
https://github.com/donl/meteor-ionic.git
synced 2026-05-27 14:22:21 -06:00
I have a url that was fetched from collection data. I was rendering the template before the subscription was done and the template data was {url: null}.
Quick fix was to only render the template when the url existed but that cased a flicker when going though routes quickly.
This fix could have been done in an autorun but given that it is only called once this makes the most sense to me.
79 lines
1.7 KiB
JavaScript
79 lines
1.7 KiB
JavaScript
IonScrollPositions = {};
|
|
|
|
Router.onStop(function () {
|
|
IonScrollPositions[this.route.path(this.params)] = $('.overflow-scroll').scrollTop();
|
|
});
|
|
|
|
Template.ionNavBackButton.events({
|
|
'click': function (event, template) {
|
|
$('[data-nav-container]').addClass('nav-view-direction-back');
|
|
$('[data-navbar-container]').addClass('nav-bar-direction-back');
|
|
|
|
//get most up-to-date url, if it exists
|
|
backUrl = template.getBackUrl()
|
|
if (backUrl) {
|
|
Router.go(backUrl);
|
|
} else {
|
|
window.history.back();
|
|
}
|
|
}
|
|
});
|
|
|
|
Template.ionNavBackButton.created = function () {
|
|
this.data = this.data || {};
|
|
};
|
|
|
|
Template.ionNavBackButton.rendered = function () {
|
|
var self = this;
|
|
this.getBackUrl = function () {
|
|
var backUrl = null;
|
|
|
|
self.data = self.data || {};
|
|
|
|
if (self.data.href) {
|
|
backUrl = self.data.href;
|
|
}
|
|
|
|
if (self.data.path) {
|
|
backRoute = Router.routes[self.data.path]
|
|
if (!backRoute) {
|
|
console.warn("back to nonexistent route: ", self.data.path);
|
|
return;
|
|
}
|
|
backUrl = backRoute.path(Template.parentData(1));
|
|
}
|
|
return backUrl;
|
|
};
|
|
};
|
|
|
|
Template.ionNavBackButton.helpers({
|
|
classes: function () {
|
|
var classes = ['buttons button button-clear back-button pull-left'];
|
|
|
|
if (this.class) {
|
|
classes.push(this.class);
|
|
}
|
|
|
|
return classes.join(' ');
|
|
},
|
|
|
|
icon: function () {
|
|
if (this.icon) {
|
|
return this.icon;
|
|
}
|
|
|
|
if (Platform.isAndroid()) {
|
|
return 'android-arrow-back';
|
|
}
|
|
|
|
return 'ios-arrow-back';
|
|
},
|
|
|
|
text: function () {
|
|
if (this.text) {
|
|
return this.text;
|
|
} else if(this.text !== false) {
|
|
return 'Back';
|
|
}
|
|
}
|
|
});
|