FAQ Database Discussion Community


Pass router parameters in Router.go()

meteor,iron-router
I have a route to display user parameters: admin/users/details/:userID In the template associated with this route I have "Back" button. What is the best way to pass "return route path" to Router.go() and access it later in Template.AdminUsersDetailsDetailsForm.events({ "click #form-back-button": function(e, t) { e.preventDefault(); Router.go(PARAM.NAME, {}); } ...

meteor iron-router and getting the names of all routes for the accounts-entry package

meteor,routing,iron-router,middleware
The popular accounts-entry package has an iron-router related bug in it. I believe the later versions of iron-router changed to work better as middleware and so a call to Router.routes At line 87 of this file the following code is used: _.each Router.routes, (route)-> exclusions.push route.name # Change the fromWhere...

meteor iron router prepends “undefined” to id

meteor,iron-router
Hi I'm following the Discover Meteor book, and I'm in Chapter 5-3. I have the router.js and post_item.html precisely as the book, and for every url, I get something like /posts/undefined<id>. I can't figure out why undefined is present in front of every id. Below is my relevant code: Router.configure({...

Route to the new data submitted by Meteor autoform using iron router?

meteor,iron-router,meteor-autoform
I'm using Meteor with AutoForm & Iron Router. I have an autoform for inserting a data, and I want to redirect to the page of the data I added after a successful insert. How should I do it? Here is the For: {{#autoForm collection="Products" id="add" type="insert"}} <h4 class="ui dividing header">Products...

Easiest way to get Json / Collection through Meteor Iron Router

javascript,mongodb,meteor,iron-router
I'm creating a set of routes, for example / - should render home page template /items - should items page template /items/weeARXpqqTFQRg275 - should return item from MongoDB with given _id This is example of what I'm trying to achieve Router.route('items/:_id', function () { var item = return myItems.find(:_id); this.render(item);...

How to get route name by URL in Meteor using Iron Router

meteor,iron-router
I know that to get current route's name I would need use do Router.current().route.getName(). What if I need to get route's name by given URL (not current URL). Let's say I have list of URLS urls = ['/orders', '/clients', '/clients/tJa84ogQ3cvpxMJ7G'] And I have following Iron Router configuration : Router.route('/orders', {name:...

Setting data that belongs to a User in iron router

meteor,user,iron-router
Router.route('/settings', { name: 'settings', data: function() { return Settings.findOne({userId: Meteor.user()._id}); } }); It's showing an error in the browser: Uncaught TypeError: Cannot read property '_id' of undefined Any suggestions on how to grab the settings record for a logged in user?...

Submit Form in Bootstrap Modal with IronRouter / MeteorJS

javascript,forms,twitter-bootstrap,meteor,iron-router
I am trying to submit a new appetizer to a web app I am creating that resembles a cookbook. The layout has a constant header/nav that allows the user to add a new appetizer, which triggers a modal and a form containing the appetizer name, description and a photo. I...

Iron Router OnBefore Hook with Params URL Not Calling Function

meteor,iron-router
I am looking to restrict access to a page using iron router, but the before function doesn't seem to be running. # Limit which challenges can seen to members. isMemberHook = () -> challenge = Challenges.findOne _id: @params._id if Meteor.userId() in challenge.members @next() else @redirect '/' Router.onBeforeAction isMemberHook, only: ['/challenge/:_id']...

Meteor: onRendered doesn't get fired again after second render iron-route

javascript,meteor,iron-router
I have an iron-router route: Router.route('/profiel/bewerken', { subscriptions: function () { return Meteor.subscribe('currentUser'); }, action: function () { if (this.ready()) this.render('profielBewerken', { to: 'container', data: function () { return Meteor.user(); } }); else this.render('profielBewerken', { to: 'container', data: { loading: true } }); } }); It waits until the subscription...

how do you get the name of the current route with Meteor Iron Router? [duplicate]

javascript,meteor,iron-router
This question already has an answer here: How to check for Route through route name in template with Meteor and Iron Router 3 answers I'm struggling to find a way to access the 'name' property of a given route. Currently I'm wanting to do this in a route, but...

Meteor: How to serve a static html file

meteor,iron-router
Im using Meteor with IRON router and it's working great for dynamic files. But I have one statis legend.html file which I want to serve. I placed it in the public folder, but I get the error that the file can't be found. As it has been generated from word,...

Using Meteor, useraccounts-core ensureSignedIn plugin won't except '/' route

meteor,iron-router,meteor-accounts
I am trying to use the ensureSignedIn plugin on all routes except for a front 'home' page that has buttons to login to separate parts of the site. Here's my route for 'home': Router.route('/', function () { this.render('home'); }); Here's the line for the plugin and exceptions: Router.plugin('ensureSignedIn', { except:...

Meteor with iron-router cant get slick carousel working

meteor,iron-router,slick-carousel
I am using iron-router, i have a route "models" which has a list of items. When the user clicks one of these items a new route "model" is used, the name of the selected item is passed as a param and used to load data about that model from the...

Router path for page navigation

meteor,iron-router
we have the problem with the router when we navigate from one to another page. Suppose when we are in template1 and we need to go to templete2.Then we do Router.go(/templete2) right.I need in the URl templete1/templete2.Please help me....

How Do I Use a Meteor Template Helper to Edit a Value Passed as a Parameter in Iron-Router?

javascript,meteor,iron-router,spacebars
How do I use a template-helper to edit the value of the parameter I passed into a route created using the pathFor method of iron-router??? I have this template-helper: Template.registerHelper('slugify', function(obj){ return _.slugify(obj); }); in my .html file I have this: {{#each menuItemsFromDB}} {{#each arrayOfMenuItems}} <a class="item category" href=""> {{this}}...

Get data size of HTTP request and response

node.js,meteor,iron-router
I'm trying to manage my Meteor web app's API usage and have two questions. How do I know how the size of the incoming POST request data? Note that I don't care about the contribution from headers; I just want to know the size of the data part. How do...

Stop users from navigating to a page that is restricted to their role

meteor,roles,iron-router
I want to restrict access to certain pages depending on users roles. So I don't want a logged in user to be able to just change the URL in their browser to navigate to a page they shouldn't have access to. So for such a route I'm doing something like:...

Return to previous path using MeteorJS and Iron Routing

javascript,meteor,iron-router
Using the latest Meteor and Iron Routing, how do I simply "go back" to the previous route? I feel silly even asking, because it seems this would be a main feature of Iron Routing.. For instance, say I went to "/contacts" from "/posts" and then I wanted to "go back"...

MeteorJS iron-router “sub-templates” or re-render prevention or optional parameter

javascript,meteor,iron-router
I'm trying to migrate a two year old meteor project with many deprecated packages to the current version. But I'm stuck with iron-router and this: A route /map showing an interactive map with markers When a user click on a marker an absolute positioned div with full-width-height opens and show...

Iron Router routing to new collection document url dynamically

mongodb,meteor,iron-router
I have a goals mongo collection. I am using Iron Router to navigate to each goal document via '/goals/:_id' This works great for clicking around the app. However, when a user adds a new goal to the collection (via server Insert method), I'd like to automatically navigate to that page...

MeteorJS : Template rendered & Meteor method call

javascript,d3.js,meteor,iron-router
This question follows my previous one : Meteor: How to publish custom JSON data I created a Meteor method building a complex JSON (built with different collections etc.). With those datas I need to build a chart using D3.js. I used to set the data in the Session but as...

Images not loading anymore when re-rendering Meteor template

meteor,iron-router
I slightly extended the discovermeteor tutorial and added an image to every post in post_item.html: <img src="discover.png" height="40px" /> After putting discover.png in the public folder everything seems to work as expected. However if you open the detail page (click on 'discuss') and come back to the overview (click on...

Using Iron Router on Server Side of Meteor Application?

mongodb,meteor,iron-router
I tried calling Router.go('confirmation') to take the user to confirmation page once the information has been inserted into the database. Meteor.methods({ 'createNewItinerary': function(itinerary){ var userId = Meteor.userId(); ItineraryList.insert({ [....values.....] },function(){ Router.go('confirmation'); }); } In the server console, I get the response: has no method 'go' The data is inserted successfully,...

Why Iron Router function doesn't redirect?

javascript,meteor,iron-router
Using FS.Collection to store files, I need to redirect to currently submitted file, but I can't get Iron Router working. It returns result._id, but don't route and just breaks. Here is the event change function for submitting files. 'change #input':function(event, template){ var email = template.find('#email').value; var title = template.find('#booktitle').value; if...

Meteor Check if Template Exists

meteor,iron-router
I have Meteor application that uses Iron-Router in which the rendered screen is dynamic based on the URL. I have two parameters from the URL, station and screen. In the routing code: this.render(stationParam+screenParam, {to: 'content'}); However, I want to be able to check if the template stationParam+screenParam exists. Is this...

Meteor template hierarchy and routing logic conflicting

meteor,iron-router,meteor-accounts
My app consists of two pages, Homepage and Dashboard. On the Homepage, I want to show Login (top nav) and Register (main body). If the user is logged in then show the Dashboard. On the Dashboard I want to show Logout option. On logout show the Homepage. Problem: When I...

Meteor: which first html file will iron-routing load

meteor,iron-router
I'm creating a Meteor application. When first creating application, Meteor has put this sample code in hello.html <head> <title>hello</title> </head> <body> <h1>Welcome to Meteor!</h1> {{> hello}} </body> <template name="hello"> Hello World Template </template> I install Iron-Router package. then here is my lib/Router.js file: Router.route('/', function () { this.render('post_template'); }); And...

Bold an active link in meteor

css,hyperlink,meteor,iron-router,active
I have this code in my navigation bar in Meteor and I'm trying to bold the link when it's active. I've tried using css and a:active {} but that doesn't seem to work. <div class="navSecondary"> <div class="menu" align="center"> <ul class="menu-items"> <li class="active"> <a href="{{pathFor 'home'}}"> HOME </a></li> </ul> </div> </div>...

page transitions in meteor - not quite working?

meteor,iron-router,velocity.js
so in the back of the 'discover meteor' book they explain how to do page transitions. i've got it working, however it causes problems with the loading of javascript functions and variables on other pages that its animating into. it seems they're not ready or simply don't exist at the...

Iron router routes from db

mongodb,meteor,iron-router
I try to load my routes from db. My collection schema for routes is: AsideMenu.attachSchema( new SimpleSchema({ name: { type: String, denyUpdate: true }, path: { type: String, denyUpdate: true }, controller: { type: String, denyUpdate: true } }) ); I defined also a method for publish and subscribe and...

Meteor : passing router parameter to get Collection data without results

mongodb,meteor,iron-router,mongo-collection
I'm fairly new to meteor and have encountered a problem while trying to use Iron Router to pass a url parameter to a Collection and retrieve some data for display. Specifically, I have a Collection with events and I'd like to have a page that display a single one in...

Dynamic URL variable for SEO with Meteor

meteor,url-rewriting,seo,iron-router
I'm working on a Meteor app which uses ms-seo package. I was wondering if there is a way to make URLs more SEO friendly? Router.route('/item/:_id', { name: 'item.detail', controller: 'ItemsController', action: 'detail', where: 'client', onAfterAction: function() { var data = this.data(); if (data) { SEO.set({ title: data.title + ' -...

Meteor Iron Router resubscribe on Rights change with meteor-roles

meteor,iron-router
I am writing a meteor application with a user-role-system (alanning:roles) My Roles are group based. When a user knows my group url, it is allowed to access the group an get the role "defaultUser" in this group. localUser is allowed to subscribe to all the local stuff of a group....

Meteor : how to publish custom JSON data?

meteor,iron-router
Edit: The solution I used is @Kyll's one. Suppose the server side objects I'd like to return are "complicated" to build and need different attributes from different collections. I first tried: /server/publications.js Meteor.publish('myCustomDocument', function(){ // suppose here that I need to X.find() different collections // and create a complex Array...

How to generate XML files in Meteor using Iron Router

javascript,meteor,iron-router
I need to generate a simple XML file to call with Twilio. Currently, I am trying to output this at a particular route: <?xml version="1.0" encoding="UTF-8"?> <Response> <Say voice="woman" language="en">Hello, world!</Say> </Response> I plan on making it dynamic later and hence, cannot place it with the other asset files. In...

Meteor Routing, Pub/Sub

javascript,mongodb,meteor,publish-subscribe,iron-router
I'm trying to make a publishment statement to publish ONLY the author(OP)'s profile avatar. I am thinking of grabbing the _id of the page. And from that page, I will grab the userId which is the author's _id and try to show the profile. However, I have been very unsuccessful,...

meteor: getting error “No Iron.Layout found so you can't use yield”

meteor,iron-router
just getting started with meteor following this autoform tutorial: http://www.webtempest.com/meteor-js-autoform-tutorial have these simple files: main.html: <head> <title></title> </head> <body> <div class="container"> <h1>Posts</h1> {{> quickForm collection="Posts" id="insertPostForm" type="insert"}} </div> <template name="main"> <div class="container"> {{> yield}} </div> </template> </body> post.html: <template name="post"> <h1>Edit...

Why would iron-router ignore waitOn?

meteor,iron-router
onAfterAction is run twice, once before the data arrives, and once after. Why is it run before the data arrives? Also, in this basic version, rendered is called after the data arrives, but in my app, it's called before the data arrives. Any idea why that might be? Basic reproduction:...

Wait On Lib (IronRouter) causing HTML to not load after loading JS file

javascript,meteor,iron-router
I'm using wait-on-lib with IRLibLoader.load() combined with Iron-Router, based on this tutorial: http://www.manuel-schoebel.com/blog/use-meteor-iron-router-waiton-to-load-external-javascript. I am trying to load external javascript code. Here is my routing code: Router.map(function(){ this.route("home", { path: "/", waitOn: IRLibLoader.load("/alert.js") }); }); The javascript loads perfectly. The problem is that whenever I am loading js files, it...

How to avoid similar route in iron-router?

meteor,iron-router
Sorry for the bad English. I have a tabs with four tab, each has a route <ul class="nav nav-tabs"> <li role="presentation"><a href="{{pathFor 'menu.tab1'">tab1</a></li> <li role="presentation"><a href="{{pathFor 'menu.tab2'">tab2</a></li> <li role="presentation"><a href="{{pathFor 'menu.tab3'">tab3</a></li> <li role="presentation"><a href="{{pathFor 'menu.tab4'">tab4</a></li> </ul> And route.js this.route('/menu/tab1', { name:...

Routing to home screen when not signed in

meteor,iron-router,user-accounts
I want to redirect all users to a home page if they are not logged in. Currently I am doing this: Router.onBeforeAction(function() { this.render('loading'); if (! Meteor.userId()) { this.render('Home'); } else { this.next(); } }); Which I saw online, but this seems to be prevent my 'loading' template from ever...

How can I detect a Router change in Meteor template to enable browser back behaviour?

meteor,iron-router
I have created a pagination with configurable limit. I am getting page number from the IronRouter. The code works when I enter url manually with different page numbers. However, when I use go back with browser back button, it does change the url and I can see beforeaction and action...

Meteor Iron Router, Pub Sub causing weird behavior

javascript,mongodb,meteor,publish-subscribe,iron-router
I am trying to make sing post page a route where it does a several things using iron:router Uses the template postPage Subscribes to publication of singlePost, userStatus (shows status and info of Author of single post page'), comments . Grabs Comments documents that has field of postId : this.params._id...

Iron router RouteController gives a not defined error

meteor,iron-router
This works fine: Router.route('/', function () { this.render('home'); }); Router.route('/about', function () { this.render('aboutView'); }); However, this gives an error (RouteController 'HomeController' not defined): var HomeController, MainController; HomeController = RouteController.extend({ action: function() { this.render('home', { }); } }); MainController = RouteController.extend({ action: function () { this.render('aboutView', { }); } });...

Iron Router: How to Provide Same Data to Multiple Routes

meteor,iron-router
It's evident how to provide route-specific data, i.e. through the use of a controller: PostController = RouteController.extend({ layoutTemplate: 'PostLayout', template: 'Post', waitOn: function () { return Meteor.subscribe('post', this.params._id); }, data: function () { return Posts.findOne({_id: this.params._id}) }, action: function () { this.render(); } }); But how does one provide data...

Meteor. Passing an argument to a helper to populate a page based on the argument

javascript,meteor,iron-router
I'm trying to populate a meteor template based on a parameter I send in through the address bar. I'm using Iron router and when I looked in its documentation I found this example Router.route('/post/:_id', function () { this.render('Post', { data: function () { return Posts.findOne({_id: this.params._id}); } }); }); I...

Cannot search meteor packages in iron-cli project

meteor,iron-router
I have a meteor iron app I generated. In the eventedmind screencast the instructor searches packages with iron search ^accounts to see all meteor packages. When I run that though $ iron search ^accounts > meteor search app bin build config readme.md How can I search for meteor packages with...

Dynamically set background-color on html tag

javascript,css,meteor,iron-router
I need to dynamically set the background-color in the html tag. <html style="background-color:{{ backColor }};"> How is this done in Meteor?...

this._id is not accessible to Iron controller in Meteor js. How to get the id?

javascript,html,meteor,iron-router
I have this in my dashboard.html {{#each todos}} <li class="list-group-item"> {{ task }} <button class="delete"> Delete</button> </li> {{/each}} and in the controller dashboard.js I have this DashboardController.events({ 'click .delete': function () { Meteor.call('ToDos.delete',this._id); } }); Without Iron Controller I can access the id of the collection in the event using...

How do I get onRendered to run a second time when the route changes but the template remains the same?

meteor,iron-router
I have an iron-router route for updating the data of a specific project: Router.route('/project/:key/update', { ... }); Each time the user navigates to an "edit project page" I want to focus the project-name input. template.onRendered(function() { this.$('form input[name="project_name"]').focus(); }); This works great when navigating from the Dashboard to any given...

Meteor: data passed to template from Iron Router, is empty at first load

meteor,iron-router
I'm facing a strange problem. I'm using Iron Router controller to pass data to template: Router.route('/wards/add/:_id?', {name: 'wards.add', controller: 'WardAddController'}); WardAddController = RouteController.extend({ action: function() { this.render('addWard', { data: function(){ return { hospitals : Hospitals.find({}), hospital_id : this.params._id } } }); } }); I return a variable 'hospitals', that should...

What is the first parameter of Router.route in Meteor's iron router?

meteor,iron-router
Reading the Discover Meteor book (and many blogs) the following syntax is used: Router.route('home', { path: '/', // ... }); But the iron router github quick guide uses: Router.route('/', { name: 'home', // ... }); And I have even seen: Router.route({ name: 'home', path: '/', // ... }); Which is...

Meteor: setting Template Title on Render

javascript,meteor,handlebars,iron-router
I have a dynamic line of code: <label>{{title}}</label> //template name="header" I'm using iron:router, the app is super simple right now: Router.configure({ layoutTemplate: 'ApplicationLayout' }) Router.route('/', { template: "home" }) Router.route('/scientific', { template: "scientific" }) I'd like a solution that doesn't rely on Session as a way to dynamically render the...

Execute route change before event function

meteor,iron-router
I've got a list of menu items and each is an a tag. Inside those, I've got notification bubbles insides a div. When the notification div is clicked, I'd like to first follow the a tag (the hash is always to a Meteor route, using Iron Router) before it executes...

iron:router + alanning:roles => why this role check working randomly?

meteor,iron-router
I'm using iron:router and alanning:roles and I want to restrict my SecretArea for only users who has been added to admin role. This works just fine if user is not logged in. But if user has logged in and she is an admin then the trouble starts. I can get...

Meteor & Iron: Using tag from array as path

mongodb,meteor,iron-router
I'm using Iron Router for Meteor and I have these routes set up and working so far: Router.map(function () { this.route('home', { path: '/', template: 'home' }); this.route('userProfile', { path: '/user/:username', data: function () { return Meteor.users.findOne({username: this.params.username})}, template: 'userProfile' }); this.route('postPage', { path: '/post/:_id', data: function () { return...

How do I force iron-router to react when the hash has not apparently changed?

hash,meteor,iron-router
When using iron-router to scroll to a hash using an anchor button referencing the id of the next section, such as this: <a class="button" href="{{pathFor 'home' hash='about'}}"> iron-router happily takes us to the about section the first time the button is clicked. if you scroll back up using the mouse...

Meteor router and url paramaters

javascript,meteor,iron-router
I'm having some trouble trying to use the URL parameters in meteor with iron:router. On the home page if my app, I display a thread of posts. But I want to allow people to select a single thread by specifying its ID in the url. Like that, when someone click...

How do I assign a custom ID to a dynamically generated URL with Iron Router in Meteor?

javascript,meteor,routing,iron-router
How do I have the URL of a dynamically generated post be one of the attributes assigned to it? Say it's name? So instead of events/vbMmmw6ymrWXjtXPd the URL is events/name-of-the-event Here's my routing so far: Router.route('/events/:_id', { name: 'event', data: function() { return Events.findOne(this.params._id);} }); And my schema: Events =...

Meteor Iron Router not loading template

javascript,meteor,iron-router
I am trying to load templates using iron router and none of the templates for the routes load. The url will change when the items are clicked but the current page never changes. Lib/router.js - Router.configure({ // we use the appBody template to define the layout for the entire app...

Please explain Meteor's Iron Router DATA and Subscribe/publish rendering

meteor,iron-router
I am frustrated with the lack of documentation around Iron Router and Collections/publish/subscribe. I have some Publish statements (on the isServer part of the code in the site) that return data from Collections to the client. I call them in the route like this: Router.route('/project/:_id', { path: '/project/:_id', template: 'project',...

Setting up simple pagination for a meteor app using Iron router and Pagination.collection()?

meteor,pagination,iron-router
Hi I have a simple app listing Posts and I am struggling to add a simple Pagination using the Iron Router along with Meteor Pagination: https://github.com/egtann/meteor-pagination I have the following in my index.js: if (Meteor.isClient) { Template.index.helpers({ posts: function () { return Posts.find({}, {sort: {voteResult: -1}}); }, } And therefore...

Meteor : subscribe to collection subset & collection total count

meteor,iron-router
Here is my issue : I'm subscribing to a subset of a Collection for "infinite pagination" in iron-router (like the Discover Meteor example) : ApplicationsListController = RouteController.extend({ template: 'applicationsList', increment: 10, limit: function(){ return parseInt(this.params.applicationsLimit) || this.increment; }, findOptions: function(){ return {sort: {name: 1}, limit: this.limit()}; }, subscriptions: function(){ this.applicationsSub...

Json page with collection data

meteor,iron-router
i am very new to nodejs and meteor. i need to create a page content-type application/json and data from mongo collection. So when collection data change json page must be change. For json page i use this example: http://stackoverflow.com/a/23666992/1446182 if (Meteor.isServer) { Meteor.startup(function () { try{ var interval = Meteor.setInterval(function()...

MeteorJs Template conditions to display different template

javascript,meteor,iron-router,meteor-helper
I have a meteorjs default layout file and i am routing to different pages using iron-route, What i am trying to do is not show navigation on the home page. I can do this by using two separate files but i want to do this with single file. <template name="layout">...

Meteor 1.0: iron-router layout on all pages but one

meteor,iron-router
I have a project that involves a dozen routes, all of which require a navbar and various other pieces that I would like to include in my layout template. My issue is that I have one and only one page that doesn't need a navbar. I could solve this by...

Meteor Iron-Router Registering helper with current route runs before router is loaded

javascript,meteor,iron-router,meteor-helper
Registering helper with current route returns error in console: Exception in template helper: TypeError: Cannot read property 'getName' of undefined And after Router is loaded - works fine. How to get rid of this console error? Helper code: if (Meteor.isClient) { // create global {{route}} helper Handlebars.registerHelper('route', function () {...

Meteor 1.0: Show loading screen on button click with iron:router

meteor,iron-router
I have a button. When this button is clicked, I would like to display the loading template (using sacha:spin) for 5 seconds. 'click #submit-air': (e,t) -> e.preventDefault() ... I'm using iron:router, and from what I've read in the docs, it seems like the answer lies somewhere in hooks, but I...

How can I set the title dynamically per page with Manuel Schoebel's SEO package?

meteor,coffeescript,seo,iron-router
With Meteor 1.0.3.1 and Iron Router, I need to set the title dynamically for some pages, while defaulting to a certain title for other pages, using Manuel Schoebel's SEO package. How can I accomplish setting a dynamic page title for a certain route? I've set SEO up generally like this:...

Meteor dynamic url explicit template finding path instead

javascript,meteor,iron-router,dynamic-url
I have a dynamic iron route with the template explicitly set, however iron router attempts to render the path instead of the template. http://localhost:3000/blog/example-post Couldn't find a template named "Blog:permalink" or "blog:permalink". Are you sure you defined it? Router.route('/blog/:permalink'), { template: 'blogPost', name: 'blogPost', path: '/blog/:permalink', data: function () {...

Getting Facebook Avatar in Meteor when Autopublish is removed

javascript,facebook,meteor,iron-router,user-profile
Currently when auto publish is removed, only {{currentUser.profile.name}} works.I'm trying to get {{currentUser.profile.first_name}} and the avatar from Facebook but have not been able to do so. Here is my code... On the Server side: Meteor.publish('userData', function() { if(!this.userId) return null; return Meteor.users.find(this.userId, {fields: { 'services.facebook': 1 }}); }); On Iron...

Iron-router base route and users routes

javascript,meteor,iron-router
Currently i'm building a social network with Meteor.js, and faced a routing problem. Thats the required router behavior: On '/', if user is not logged, redirects to a langing page with login. On '/', if user is logged in, grabs his username and redirects to a profile page by '/:username'...

Correct way to manage routes after sign in for different roles

meteor,roles,iron-router
I have 2 roles, admins and users. I have a home route '/' that is just a sign in page. When admin users sign in they must go to one route ('adminPortal') and when user users log in they must go to the 'userPortal' route. On signing out both roles...

Meteorjs iron:router data

meteor,iron-router
I have this route: Router.route('/', { name: 'index', template: 'index', data: function () { console.log(Meteor.user()); } }); In browser console, first it displays: null and right after: Object {_id: "aSeHqtE8o7C3x5NsW", profile: Object, username: "torayeff"} Can anyone explain the reason for double output?...

How to reuse layoutTemplate between routes?

meteor,iron-router
Looking at devtools profiling, when I move between two routes with the same layoutTemplate, the layout's helpers are being rerun, and it looks like the HTML is being rerendered as well. How can I have iron router only render the yields and leave the layout alone? EDIT code: Router.map ->...

How can I publish the same collection with different subsets of data?

javascript,meteor,iron-router
I have collection called Rooms, now, I want to publish different subsets of Room depending on where the user is on the app, so, this is what I had in mind: Meteor.publish('roomList', function() { return Rooms.find({}, {fields: {'roomId': 1, 'playerCount': 1, 'isPlaying': 1}}); }); Meteor.publish('roomInfo', function(_id) { return Rooms.find({_id: _id},...

Pass file across route in Meteor

javascript,file,meteor,iron-router
One one page, I have a file selector input. When the user selects a file, I would like user to be directed to a separate route that contains an interactive image cropper that is used to prepare the image before I upload it to the server. Since I would like...

How do I unsubscribe from the subscription set by Iron Router's waitOn?

meteor,iron-router
I have a list of items fetched from a collection and I want to make it show different stuff depending what button is clicked. I figured I'd do this via sessions that update the publication. Here's my publication: Meteor.publish('stuff', function(filter) { var nameVar = filter || "default" return myStuff.find({name: nameVar})...

Meteor Iron router hooks being run multiple times

javascript,meteor,iron-router
EDIT: Here is the github repo. And you can test the site here. On the homepage, just open the browser console and you will notice that WaitOn and data are being run twice. When there is no WaitOn, then the data just runs once. I have setup my pages by...

Meteor with Iron Route PathFor

javascript,meteor,iron-router
When I click on user's name, I want the link to go to their profile page. I am using Meteor with iron router. Here are the defined routes: Router.route('/', { name: 'JobsList'}); //homepage with all users //this is where the user's profile is located and works: Router.route('/company/:_id/', { name: 'CompanyPage',...

How Do I Properly Set Active Navigation Tab When Pressing the Back Button in Meteor Application?

javascript,css,meteor,iron-router
I have a multipage meteor application with a navigation template included in each page. I use iron-router to switch between pages. I indicate which page the user is on by setting the appropriate navigation link's class to 'active. Example: navigation.html <li class="{{navClassName 'page1'}}"> <a href="/page1">Page 1 </a> </li> <li class="{{navClassName...

How to check current route in Iron Router Meteor

javascript,templates,meteor,iron-router
I'm setting up a body helper for use with Iron Router to use as {{route}}: Template.body.helpers({ route: function(){ alert(Router.current().route.getName()); } }); But Router.current().route.getName() returns undefined instead of "/thirdPage/"....

Meteor Iron Router : Loading public resources in inner routes

meteor,iron-router
In my meteor application I have a nested route this.route('assemble', { path: '/assemble', title: 'Assemble', parent: 'home', controller: 'MainLayoutController' }); this.route('bottypelist', { path: '/assemble/bottypelist', title: 'BotType - List', parent: 'assemble', controller: 'MainLayoutController', waitOn: function(){ return Meteor.subscribe('myBotTypes'); } }); The layout controller loads a logobar on the top. The layout template...

Meteor iron-router subscription. How to make subscriptions with a few linked parameters?

meteor,iron-router
I'm got a route with few subscriptions where each one with some parameters for limiting data. Already known parameter only for first subscription, but all other based on data from item of first subscription. How i can handle it? Example (coffeescript): Router.route '/survey/:id/', name: 'survey', waitOn: -> Meteor.subscribe 'surveys', @params.id...

Meteor & iron-router: TypeError: undefined is not a function

javascript,meteor,iron-router
I have made simple page without routing and it work's nice, but after adding routing i'm have this error in my browser console: TypeError: undefined is not a function My router.js: Router.configure({ layoutTemplate: 'layout' }); Router.map(function() { this.route('index', {path: '/'}); }); My layout.html: <tempate name = "layout"> <html> <head> ......

Why does route to home changes after rendering a template?

meteor,iron-router
I am just getting started using the iron:router package. These are my project files: router-example.js if (Meteor.isClient) { //some code } if (Meteor.isServer) { //some code } Router.route('/', function(){ this.render('Home'); }); Router.route('/hello', function(){ this.render('hello'); }); Router.route('/items', function(){ this.render('Items'); }); Router.route('/serverItem', function(){ var req = this.request; var res = this.response; res.end('Hello...

What's the correct way to create a global iron:router subscription?

javascript,meteor,iron-router
I need a particular subscription for every route in my app, this works but I'm unsure if it is correct? Router.onBeforeAction(function() { Meteor.subscribe('locations'); this.next(); }); Also, is there a way to waitOn() globally?...

How to jump 2 pages before using iron router?

javascript,meteor,iron-router
I want to jump to the previous page using iron router. Normally, I would have used the history.back() function but in this case, I use yield templates. The page I am in is reached using myWebsite.com/page which redirect to myWebsite.com/page/sub-page in order to display the default yield content. Tell me...

I'm using iron:router v1.0.7 but this.render() is “undefined”. I can't see what I'm doing wrong

javascript,meteor,iron-router
I'm displaying an access denied template when the visitor tries to visit the Submit page. This works fine. Here is the code: Router.route('/', {name: 'etoeventsList'}); Router.route('/submit', {name: 'etoeventSubmit'}); var requireLogin = function () { if (!Meteor.user()) { this.render('accessDenied'); } else { this.next(); } }; Router.onBeforeAction(requireLogin, {only: 'etoeventSubmit'}); I want to...

Does IR redo global waitOn subs between routes?

meteor,iron-router
Router.configure waitOn: -> Meteor.subscribe 'data' Does data get torn down and re-subscribed to when I switch from /bar to /foo, or does it stay subscribed to for the entire session, like the null publication?...

Meteor - Multiple data contexts with Iron Router

meteor,iron-router
I just started using Meteor and Iron Router. Here I'm trying to use two data contexts but appearantly I'm doing it wrong. I've googled it but it doesn't seem this is a very common problem, but I guess it got to be possible to pass on two or more data...

Trouble publishing/subscribing to a Mongo aggregate query

mongodb,meteor,aggregate,publish-subscribe,iron-router
Using Meteor and Iron-Router, I'm trying to publish the following mongo query (in the server folder): Meteor.publish("getTestList", function() { return Tests.aggregate( [{ $project : { "name" : 1, "description" : 1, "testNumber" : 1 } }, { $sort : { "testNumber" : 1 } } ]) }); Note that I...

Meteor - Router.go() doesn't run when passed a variable

templates,meteor,static,path,iron-router
I have a template for a back button I've been reusing: <template name="btnBack" label="" path=""> <a href="" data-path="{{path}}" class="btn btn-info btn-small" role="button"> <span class="glyphicon glyphicon-menu-left" aria-hidden="true"></span> {{label}} </a> </template> I pass it two fields, label and path statically. My intention is to pass the static path field to Iron-Router to...

Iron Router URL Extension

meteor,iron-router
So I have a user profile and would like to have a "Favorites" section linked to it where favorited posts are displayed. My user profile URL looks like this in Iron Router: path: '/:username' And my "Favorites" URL looks like this: path: '/:username/favorites' And I'd like my user profile to...

How does Iron-router determine route priority?

meteor,routing,iron-router
Let's say you have the following route definitions: @route "home1", path: "/:homeSlug1 and @route "home2", path: "/:homeSlug2 and @route "home3", path: "/fixedPath and then go to localhost:3000/fixedPath in the browser how does Iron-Router choose the priority? It does not appear that the fixedpath route takes precedence over the parameterized route....

How can I dynamically set router options in a Meteor application using the iron router package?

meteor,iron-router
I would like to set a route option label to that of the current url, e.g. Router.route('/:_url', { label: '_url', action: function () { this.render('home'); } }); This is my helper: if (Meteor.isClient) { Template.home.helpers({ getLabel: function() { return Router.current().route.options.label; } }); } This is my template: <template name="home"> hi...

Meteor: iron-router => waitOn without subscribe

meteor,loading,iron-router
i want a loading template to appear before the site has all data to be rendered. And after the serverside Method gives me the Data(from an API [async]) via Meteor.call i want to load the correct layout. I tried many ways found on Google which describe similar but not exatcly...

Cant read properties of Object in meteor 's iron router's route

javascript,meteor,iron-router
I want to pass object in data context in route. I am trying to read JavaScript object(which holds the business logic) . If i send the object as such , then i can read it's properties in template. But if i try to send a custom object by reading some...

Meteor find not returning data

javascript,mongodb,meteor,iron-router
My collection is created in collections.js portfolioCategories = new Mongo.Collection('portfoliocategories'); It is then subscribed to in subscriptions.js Meteor.subscribe('portfoliocategories'); And published in publications.js Meteor.publish('portfoliocategories',function(){ return portfolioCategories.find(); }); If I query Mongo from the server with db.portfoliocategories.find() I'll get { "_id" : "W9AeauCpMgPw2j5hf", "title" : "Commercial Design", "slug" : "commercial-design", "image" :...