Closed sherwyns closed 10 years ago
It would be great if you could post a snippet of the code from your routes.js (or wherever you have your routes defined) so I could get the whole picture.
BTW, please use markdown to format the code when posting.
Let me know if this is what you are looking for -
Router.configure({
layoutTemplate: 'layout',
yieldTemplates: {
'header': {to: 'header'},
'leftSidebar': {to: 'leftSidebar'},
'footer': {to: 'footer'}
},
preloadFiles: {
// Use these on *ALL* pages
'common': {
js: ['http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js',
'http://cdnjs.cloudflare.com/ajax/libs/jQuery-slimScroll/1.3.1/jquery.slimscroll.min.js',
'http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.1.1/js/bootstrap.min.js',
'http://cdnjs.cloudflare.com/ajax/libs/foundation/5.2.3/js/foundation.min.js',
'http://cdnjs.cloudflare.com/ajax/libs/velocity/0.0.22/jquery.velocity.min.js',
'http://cdnjs.cloudflare.com/ajax/libs/velocity/0.0.22/velocity.ui.js',
'/vendors/bootstrap-datepicker/js/bootstrap-datepicker.js',
'/vendors/jquery.loadingbar/jquery.loadingbar.min.js',
'/vendors/jquery-knob/js/jquery.knob.js',
'/vendors/jquery.easy-pie-chart/dist/jquery.easypiechart.min.js',
// '/vendors/jquery.sparkline/dist/jquery.sparkline.min.js',
'/vendors/jquery-autocomplete/jquery.autocomplete.min.js',
'/vendors/jquery.growl/javascripts/jquery.growl.js',
'/scripts/startup.js'
],
css: [
'/css/style.css',
'http://fonts.googleapis.com/css?family=Open+Sans:400,700,300,600',
'http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css',
'/vendors/jquery.loadingbar/loadingbar.css',
'/vendors/jquery.growl/stylesheets/jquery.growl.css',
'/vendors/jquery.growl/stylesheets/jquery.growl.css'
]
}
},
preloadHandler: function(filePath) {
console.log(filePath);
return true;
},
});
Router.onBeforeAction(function(pause) {
if (!Meteor.loggingIn() && !Meteor.user()) {
Router.go('login');
pause()
}
}, {except: 'login'});
Router.map(function() {
this.route('index', {
path: "/",
controller: PreloadController,
waitOn: function() {
return this.preload({});
}
});
this.route('pressLink', {
template: 'pressLink',
controller: PreloadController,
waitOn: function() {
return this.preload({});
}
});
this.route('login', {
layoutTemplate: 'signIn',
template: 'login',
controller: PreloadController,
waitOn: function() {
return this.preload({});
}
});
this.route('productDetail', {
template: 'productDetail',
controller: PreloadController,
waitOn: function() {
return this.preload({});
}
});
});
Thank you! I've been able to pinpoint the root cause.
Please update the package (mrt update
).
Oh, by the way, since v0.3.0 you don't have to use
waitOn: function() {
return this.preload({});
}
anymore - it's all automagic now ;)
Here is the error I am getting -
Exception in defer callback: TypeError: Cannot read property 'async' of undefined at RouteController.extend.onRun (http://localhost:3000/packages/preloader.js?2255f007c283a1450640ad6266d97c9b7c5618e2:324:39) at RouteController.runHooks (http://localhost:3000/packages/iron-router.js?10a100ab994fa9eac06d91712a861bf78d6be533:851:16) at http://localhost:3000/packages/iron-router.js?10a100ab994fa9eac06d91712a861bf78d6be533:2199:16 at http://localhost:3000/packages/iron-router.js?10a100ab994fa9eac06d91712a861bf78d6be533:2187:21 at Deps.Computation._compute (http://localhost:3000/packages/deps.js?d9b2b2601bdab0f57291b38e7974a7190b8aac01:214:36) at new Deps.Computation (http://localhost:3000/packages/deps.js?d9b2b2601bdab0f57291b38e7974a7190b8aac01:148:10) at Object.Deps.autorun (http://localhost:3000/packages/deps.js?d9b2b2601bdab0f57291b38e7974a7190b8aac01:362:11) at http://localhost:3000/packages/iron-router.js?10a100ab994fa9eac06d91712a861bf78d6be533:2197:12 at http://localhost:3000/packages/iron-router.js?10a100ab994fa9eac06d91712a861bf78d6be533:2187:21 at Deps.Computation._compute (http://localhost:3000/packages/deps.js?d9b2b2601bdab0f57291b38e7974a7190b8aac01:214:36) debug.js:41