iron-router

Meteor router doesn't render the template

旧时模样 提交于 2019-12-24 00:02:23
问题 I created a route and gave it a path to a template. But when I run the application, it says that 'there is no route'. Router simply doesn't follow the path. (I am sure the router package is installed because if I don't create and specify any route, on the main page appears the default message how to use a router) HTML: <head> <title>todos</title> </head> <body> {{>todos}} </body> <template name="register"> <h2>Register</h2> </template> route.js: Router.route('/register'); 回答1: Creating a new

Meteor.js - Check logged in status before render

白昼怎懂夜的黑 提交于 2019-12-23 10:06:29
问题 First off lets just start with the fact that I am a complete noob with Meteor. Now that that is out of the way let the problem begin... I have two pages, a splash page at '/' and a home page at '/home'. I am using iron-router for the routing. Now If I am not logged in and on the splash page and login I have it redirecting to the home page this works. Now if I close my browser and reopen and goto the '/' it loads for a few seconds then realizes that I am actually still logged in and then

Totally confused about this.next() in Meteor iron-router

孤人 提交于 2019-12-23 07:49:01
问题 I upgraded to Meteor 1.0, installed the latest iron-router package, tried to run my app and got this nice warning in my console log: Route dispatch never rendered. Did you forget to call this.next() in an onBeforeAction? So I tried to modify my routes according to the new version. this.route('gamePage', { path: '/game/:slug/', onBeforeAction: [function() { this.subscribe('singlePlayer', this.params.slug).wait(); var singlePlayer = this.data(); if (singlePlayer) { if (singlePlayer.upgrade) {

Iron Router Route Allow/Deny

梦想与她 提交于 2019-12-23 02:52:30
问题 I'm writing a a meteor application right now, and am getting used to the new Iron Router package (as opposed to the router package that I used before). I have a collection of routes that should only be accessible by users with specific properties. To be specific, I'm using the Roles package. My way of achieving this at the moment is to define a before function that runs a conditional, and redirects to a login or error page if the user doesn't have the proper role. Here's just a quick

Meteor.user() returns undefined after page reload

为君一笑 提交于 2019-12-22 04:55:14
问题 Thing is I want to check if the user is is logged in via Meteor.user() within onBeforeAction in my routes. Problem is, after a page reload Meteor.user() returns undefined for a split second before it gets loaded. Here my route config: Router.map(function() { this.route('list', { path: '/list', template: 'list', onBeforeAction: function(){ console.log('onBeforeAction'); if(!Meteor.user()){ Router.go('/login'); } this.next(); } }); }); I googled a lot and the workarounds with "waitOn" and

Meteor Iron Router with custom waitOn

谁说我不能喝 提交于 2019-12-22 01:17:09
问题 I was wondering whether anyone has built their own waitOn function? I am not using subscribe to drive the waitOn but rather I want to wait on a helper to trigger the ready state, something like this: this.route('edit_Record', { path: '/record/edit/:_id', waitOn: function() { return XXXXX; } }); Template.edit_Record.helpers({ selectedRecord: function () { wait(3000); var x = myRecords.findOne({_id: this.editid}); //XXXXX This is where I want to set 'ready' return x; } }); 回答1: I've designed my

Tell Iron Router not to intercept a link

大城市里の小女人 提交于 2019-12-21 17:43:33
问题 I'm moving quite a large application to Iron Router. On the client side, all unknown routes are redirected to /404 . In addition, some routes are managed from the server side - for example /static , that just displays a static page via middleware. The problem is that Iron Router now intercepts all link clicks - so when I click a link to /static , the action is prevented, browser does not display the server response for that address, and user is redirected to /404 instead. How do I prevent

iron:router will not re-render after route change with same template

不想你离开。 提交于 2019-12-21 09:19:36
问题 How can I make Iron:router re-render a template? I have this html: <head> </head> <body> </body> <template name="mainLayout"> <a href="{{pathFor route='list'}}">list</a> <a href="{{pathFor route='find' query='q=xxx'}}">find</a> {{> yield}} </template> <template name="listTemplate"> <p>list</p> </template> and this js: Router.configure({ layoutTemplate: 'mainLayout' }); Router.route('/list', { name: 'list', template: 'listTemplate' }); Router.route('/find', { name: 'find', template:

Router waitOn waits on subscription on every render

▼魔方 西西 提交于 2019-12-21 02:03:52
问题 I have a route with a waitOn hook that returns a Meteor.subscribe . Every time the route is triggered, I see the spinner from my loadingTemplate briefly before seeing the actual data. I would have thought that I only had to wait on the subscription to be downloaded once, namely the first time? If I'm doing it wrong, please suggest a better way. 回答1: Have a look at the last comments on this issue. Chris explains that the subscriptions initiated by your router will be stopped once you navigate

Meteor Iron Router : Passing data between routes

杀马特。学长 韩版系。学妹 提交于 2019-12-20 18:46:31
问题 How do I pass data between two different routes and templates? I have a javascript file on the front end (client folder) that simply calls Router.go() passing in the post ID as one of my parameters. Below are the three main culprits (I believe). I've removed most of the code to make it easier to read. I can change to the PostDetail page with no problems. I can also retrieve the PostId on the PostDetail page from the Router. My problem is, the database entry ( POLL ) that is retrieved does not