FAQ Database Discussion Community


How do I do an analog of a page scope in variable in Meteor?

meteor,meteor-helper
I have this Meteor layout: <template name="layout"> {{> toolbar }} <div class="container"> {{> yield}} </div> </template> Router.configure({ layoutTemplate: 'layout' }); I want to have the toolbar argument display dynamic content based on the page. I could do that by using some reactive variables. However, what happens when more than one...

Meteor ReactiveVar doesnt works with Meteor.call in event

meteor,meteor-blaze,meteor-helper
I am using ReactiveVar. onCreated I set ReactiveVar with Meteor.Call. When I try to change my reactive variables from event, I am getting Exception in delivering result of invoking 'namelist' Hope my code below will explain my problem more. Template: <template name="Name"> {{#each list}} Name : {{name}} Age : {{age}}...

Making functions specific to Meteor templates and accessible by its event handlers

javascript,meteor,meteor-helper
Is there a way in which I can make functions that are specific to the template and accessible by the template's event handlers? I don't want to pollute the global namespace. I came upon this problem when I first noticed that I was repeating a lot of code between my...

Execute Code After Meteor Helper Returns

javascript,meteor,meteor-helper
I need something to work like a callback for a Meteor helper, such that it runs every time the helper updates/returns. I can't include it in the helper definition because a) it would run before the helper returns, and b) as far as I can tell that code only runs...

Meteor app is printing [object Object] instead of values?

meteor,meteor-helper
Attempting to learn Meteor. I went through the Discover Meteor book and am now trying to create a simple app myself, but I'm stuck just setting up some basic templates and routing. Rather than displaying the values of the object out, I'm getting [object Object] instead. I read in another...

Meteor Spacebars nested tag equivalent

meteor,handlebars,spacebars,meteor-helper
I have a problem. I have a collection of documents in my database, and I would like to display each document depending on whether a session variable corresponding to that document is set. To illustrate my problem, let me give a simplified example. Meteor.myTemplate.helpers({ stuff: [ {name: 'item1'}, {name: 'item2'}...

Meteor ReactiveVar - TypeError: Cannot call method 'set' of undefined

javascript,meteor,meteor-autoform,meteor-helper
I tried to use ReactiveVar. I doesnt know how to handle ReactiveVar. Here the code I have tried. Template.Home.helpers({ names: function(){ temp = Template.instance().name.get(); return temp; } }); Template.Home.onCreated(function () { this.name = new ReactiveVar(); Meteor.call("getNames", function(error, result) { if(error){ alert("Oops!!! Something went wrong!"); return; } else { this.name.set(result); //...

Use UI or Template for helpers

meteor,meteor-blaze,meteor-helper
I'm just learning Meteor and I've defined a few helpers that I use in my templates. I've noticed that I can do this in two different ways, but which solution is considered best practice? And why? Solution 1 UI.registerHelper('firstChar', function (name) { return name.charAt(0); }); Solution 2 Template.registerHelper('firstChar', function (name)...

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">...

Loading fields from collection into select field and filtering it based on selected value

javascript,meteor,meteor-helper
Basically i have two questions which are related but i'll separate them with numbers 1) I am trying to load a single field into a select dropdown box from collection but its populating with all repetitive values it collected from the list below it instead of its own helper. <template...

Meteor collections: how to connect to different collections referring to each other?

meteor,meteor-helper,meteor-collections
I have two collections: Contracts = new Mongo.Collection('contracts'); Reminders = new Mongo.Collection('reminders'); These are structured in the database more or less like this: Contracts: { "id": "4432234", "contract": "C-42432432", "description": "Description of contract", "counterpart": "Company name", "status": "awarded" }, etc. Reminders: { "name": "Contract expiring", "type": "expiring", "contract": "C-42432432", "reminderDate":...

event.target is undefined in events

javascript,meteor,handlebars.js,meteor-blaze,meteor-helper
How to use each input values in events? Hope my below code will explain you well. HTML: <template name="UpdateAge"> {{#each Name}} <div data-action="showPrompt"> <div> Some content </div> <div> <div> Some content </div> </div> <div> Name : {{name}} Age : <input type="text" name="age" value="{{age}}"/> //I need to access age values in...

How to print key and values in Meteor Template?

javascript,meteor,handlebars.js,meteor-helper
I have JSON from helper { "Name": "abc", "Age": 24, "Address" { "street" : "xyz street", "city" : "zyz city", "country" : "XY" } } I want to print the address with key and values <template name="User"> {{#with user}} Name : {{Name}} Age : {{Age}} {{#each Address}} {{key}} : {{value}}...

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 () {...

Filtering records according to dropdownlist

meteor,meteor-helper
I need to filter the listing or records according to selection in dropdownlists. I have three dropdowns that needs to filter the records reactively in collaboration with each other. i.e value selection in one dropdownlist should filter the records effected by other dropdownlist values. var filterAndLimitResults = function (cursor) {...

Filter collection based on select dropdown box in meteor

javascript,meteor,meteor-helper
I am trying to filter my collection based on the selection of value from select dropdown list. I have tried with the solutions here and here and its not working enough for me. Below is the template where i want to filter.the select dropdown is in another template categoryFilter which...

Meteor template not updating when template helper re-runs

meteor,reactive-programming,meteor-autoform,meteor-helper
I am trying to make a custom form wizard that will contain different autoform steps based on certain conditions. A simplified meteorPad example is linked below. When the reactive data source(session variable) changes the reactive computation(template helper) runs, confirmed by console output. The template, however, is not updated and still...

Use ReactiveVar in {{each}} helper

meteor,meteor-helper
I have a ReactiveVar in my helper which returns a number of photos to be placed in a template photoCount:-> Template.instance().rvPhotoCount.get() Now I need to reactively populate my html with a # of img returned by photoCount. I tried using {{each photoCount}}<img> but receive an error {{#each}} currently only accepts...

Meteor template: What's the simplest way to check if a user is logged in?

meteor,meteor-blaze,meteor-accounts,meteor-helper
I'm using Meteor's accounts-ui. Is there a way to check if the user is logged in on the template without writing custom helper code? Pseudo code: {{#if userIsLoggedIn }} You're logged in {{/if}} If not, what's the cleanest, most idiomatic way of doing it? I only care about client-side here....

Meteor.js: Reusing methods and functions in events and helpers

javascript,meteor,meteor-helper
I'm new to Meteor.js and would greatly appreciate any help anyone could give on the following two questions. I'm making a flashcards app, where you click the arrow to show the next flashcard. The flashcards are shuffled beforehand, and you go through the entire deck by clicking the arrow. Router.route...

Why are my meteor settings not being passed to the application?

meteor,meteor-helper
set METEOR_SETTINGS={"public": {"stage": "development"}} meteor Then this line: console.log(Meteor.settings.public.stage); causes this error: W20150612-20:45:38.338(-7)? (STDERR) TypeError: Cannot read property 'stage' of undefined What am I doing wrong?...

Meteor: Access Template Helper (or variable) from another helper

meteor,meteor-blaze,spacebars,meteor-helper
How can I reference a template helper from another one? For example... Template.XXX.helpers({ reusableHelper: function() { return this.field1 * 25 / 100; //or some other result }, anotherHelper: function() { if (this.reusableHelper() > 300) //this does not work return this.reusableHelper() + ' is greater than 300'; else return this.reusableHelper() +...

Access an original TemplateInstace from the helper in Meteor

meteor,meteor-helper
Could anybody point me how to access an original TemplateInstance from the meteor helper. I'm aware of the Template.instance() but it appears to return the template instance where the helper was called, not the template instance for which the helper was defined. Imagine we have two tiny templates: <template name='demo'>...

meteor : How to print an array from meteors helper

javascript,meteor,meteor-helper
I want to generate ul li tag from meter helper. Result: <ul> <li>aaa</li> <li>bbb</li> </ul> my template code is <template name="Mytempalte"> <ul> {{#each Name}} ??? {{/each}} </ul> </template> and my helper returns an array. Template.Mytempalte.helpers({ Name : function(){ return ["aaa","bbb"]; } }); ...

Change Body Class Based On URL in Meteor

jquery,meteor,meteor-helper
I have a template named layout in my app. Inside has: <body id="body class="{{blue}}> Basically what I want to achieve is that when you hit a url, for example, www.abc.com/sky, I want to add a body class of blue: <body id="body class="blue"> In my client folder I have this but...

how to display static html files using iron router

javascript,meteor,meteor-helper
I want to render normal html files using iron router.however when i try to do that its showing me other template instead of the template i am attaching it using iron router. this is my main layout <template name="mainLayout"> {{> yield region="navBar"}} {{> yield}} {{> yield region="footer"}} </template> This is...

How can I pass parameters to an helper?

javascript,meteor,spacebars,meteor-helper
I want to pass some parameters from my HTML to my meteor helper. Can I do something like this? -> {{myHelper "customText"}} or {{myHelper context="customText"}} If so, how do I get back the string "customText"? Is it something like this? -> "myHelper": function(context){ return this.dataset[context]?"success":"danger" }, thanks!...

How can I change dropdown text on ian:accounts-ui-bootstrap-3

meteor,meteor-accounts,meteor-helper
I have a helpers/config.js Accounts.ui.config({ }); After playing around with this for a couple hours and searching I've been unable to find a way to change the tex SIGNIN/JOIN that is generated in the top bootstrap nav. How do I do it the right way? ...

Dopdownlist is being populated with limited values instead of values from total collection

javascript,meteor,meteor-helper
I have a dropdownlist as filters and then there's the total posts with a limit of displaying only 4 at a time unless a load more button is clicked to show another 4 records. problem is the dropdownlist is also loading values only from that first 4 records. Here is...

How can fetch the text from html tag in meteor template event?

jquery,templates,javascript-events,meteor,meteor-helper
How can I get "option 1" from below code: <template name="MyTemplate"> <div class="dropdown"> <a class="dropdown-toggle count-info" data-toggle="dropdown" href="#" aria-expanded="false"> <button type="button" class="btn btn-sm btn-primary">Add</button> </a> <div class="dropdown-menu dropdown-alerts"> <form method="post" id="some-form" data-remote="true" accept-charset="UTF-8"> <div class="form-group"> <label>Select Option</label> <div class="input-group">...

Passing two class to meteorjs click event?

javascript,jquery,templates,meteor,meteor-helper
Passing two class to meteorjs click event. I have two buttons save and close which have same functionality and i want to target them using meteor events. I know i can assign them same class or create two separate events. But is there any way to target it with something...

Use a “months” array to perform calculations for each month in a for loop

javascript,arrays,meteor,meteor-helper
I have a mongo collection to store "projects", each document stores a project with different calculations for each month of the year a_jan : 10, a_feb : 20, a_mar : 25, a_apr : 70 ... b_jan : 30, b_feb : 10, b_mar : 20, b_apr : 70 ... c_jan :...

Meteor Template.registerHelper() not working within {{#if}} block

meteor,meteor-blaze,meteor-helper
Defined 3 global helpers in Meteor as follows: Template.registerHelper('activeTrips', function () { console.log("Global Active Trips"); return Trips.find().count(); }); Template.registerHelper('isSuperUser', function () { console.log("Global isSuperUser"); return Meteor.user().username === "superuser"; }); Template.registerHelpr('isAdminUser', function () { console.log("Global isAdmin"); return Roles.userIsInRole(Meteor.user(), ['admin']); }); Used as template count displays {{activeTrips}} displays count correctly! But other...

implement Infinite Scrolling on click of button in Meteor

javascript,meteor,meteor-helper
From publication i am setting an argument called limit. and this is my controller MainPageController = BaseController.extend({ findOptions: function() { return {sort: {createdAt: 1}}; }, waitOn: function() { return Meteor.subscribe("allCars",5,this.findOptions()); }, data: function(){ return {cars: Cars.find({},this.findOptions() )}; } }); in my Template i have a button on click of which...