iron-router

meteor js iron router: apply CSS change whenever route changes

跟風遠走 提交于 2019-12-28 13:57:50
问题 I have homepage, contact page, and several other product related pages in my app. The goal is to apply a background image to ONLY specifc routes: /homepage and /contact . If user navigates away from either route, apply some css change. I am hacking this together now with a helper on my homepage, like so: Template.homepage.rendered = function () { var route = Router.current(); if ( route.path == '/' ) { document.body.className = "showBackgroundImage"; } }; Partial win here, since this will

IronRouter: template is rendered before call in waitOn is finished

不羁的心 提交于 2019-12-25 04:27:12
问题 I want to create charts based on data from my collection. This data is called by an aggregate pull in my router-settings and set by Session.data in the template.rendered function. The Meteor.call is placed in the waitOn-function. If the template is rendered, the data is not present. I tried onBeforeAction, action, setTimeout... but i can't set the render-function to wait until the call-data is present. I tried to set the calls in the onBeforeAction and onRun hooks, in the action, waitOn and

Tracker afterFlush error : Cannot read value of a property from data context in template rendered callback

守給你的承諾、 提交于 2019-12-25 04:12:21
问题 I'm making a simple Meteor app that can redirect to a page when user click a link. On 'redirect' template, I try get the value of property 'url' from the template instance. But I only get right value at the first time I click the link. When I press F5 to refresh 'redirect' page, I keep getting this error message: Exception from Tracker afterFlush function: Cannot read property 'url' of null TypeError: Cannot read property 'url' of null at Template.redirect.rendered (http://localhost:3000

Meteor/Iron-Router: how to define routes using data from settings.json

本秂侑毒 提交于 2019-12-25 03:44:58
问题 For the URL to which a route applies I have a part defined in settings.json, like this baseUrl: '/private' My settings are published and accessible through the collections 'Settings' (on the client). So I tried the following: Meteor.subscribe('settings'); Deps.autorun(function () { var settings = Settings.findOne(): if (settings) { Router.map(function () { this.route('project', { path: settings.baseUrl + '/:projectId, controller: 'ProjectController' }); }); } }); The problem is that during

Unable to view user profiles when logged out (Meteor&Iron Router)

谁说胖子不能爱 提交于 2019-12-25 01:37:26
问题 I've built a user profile page for an app that I'm developing, the page works fine when an user is logged in, but when nobody is logged in the templates are empty. My goal is that anyone (even if it isn't registered in the app) is able to see the user profiles. Here is the code: Publication: Meteor.publish('singleUser', function(userId) { if (this.userId) { var findById = Meteor.users.find(userId); return findById.count() ? findById : 'undefined'; } return []; }); Router: this.route('user

Meteor nested views and yields

牧云@^-^@ 提交于 2019-12-24 14:28:32
问题 Iam setting up a basic structure of my future meteor app, Iam using meteor and angular. Wanted to combine iron router with ui router but it got pretty bad. So now Iam back on vanilla meteor for routing issue and the task is have standard multipage site but one of the pages is a complex panel with its own subpages. So I have a global layout with >yield and all content is being rendered there, now this dasboard page is also rendered into this yield, but it has to have yield of its own. How to

Is there a way to access Iron Router parameter from template in Meteor

≯℡__Kan透↙ 提交于 2019-12-24 14:24:26
问题 I have a route that has a parameter in it and I need to access it from many different templates. Below is one example of the route, there are several routes that are very similar just after the _occasionnId parameter it changes: For example: Route 1: /occasions/:_occasionId/cards/ Router 2: /occasions/:_occasionId/tables/ Here is my full code for each route, the only thing that really changes is the route path and the template. Router.route('/occasions/:_occasionId/cards/', { template: 'cards

Iron Router hook on a route before actually changing the template

▼魔方 西西 提交于 2019-12-24 08:31:04
问题 i am trying to show the user a payment popup as soon as he clicks on a payed object. But after he pays he should directly enter the content he clicked on. Therefore i think its a good solution to solve this with the router, because i want every link on the page that redirects to this content to show this popup. My problem is i want to show the popup before redirecting the user. So i tryed the onBeforeAction hook and stuff but everything working with the iron router seems to only hook in after

Iron Router: How do I send data to the layout?

。_饼干妹妹 提交于 2019-12-24 04:26:10
问题 Using Iron Router, I understand how to set data for a template. But how do I send data to a layout that was globally defined? I set the router layout by: Router.configure({ layoutTemplate: 'NAME' }) This will set the layout for all my routes. However from my individual routes, I'd like to send data to the layout template. 回答1: The layout uses the data context defined with data in the route option. Here is an excerpt from Iron Router documentation: Router.route('/routeName', { ... // A data

Iron router meteor auto unsubscribe?

时间秒杀一切 提交于 2019-12-24 02:33:29
问题 When using iron router to change to different template(pages), does it auto unsubscribe collection that no longer required ? Below scenario explain the question on page1, we call Meteor.subscribe(document, id) iron router change to page 2 on page 2 , we call Meteor.subscribe(document,id2) , does step 1 auto unsubscribe ? 回答1: See here: https://github.com/EventedMind/iron-router/issues/265 Iron Router/Meteor does this for you: If you call Meteor.subscribe within a reactive computation, for