Thursday, June 9, 2016

Meteor Template undefined

I was trying to invoke a function from within a template. For example in html file i had the following:




 <template name="docTypesTemplate">  
               {{#each types}}  
                 do something ...  
               {{/each}}    
 </template>  


And in my JS file I had:


 Template.body.helpers({    
   types() {    
     return DocTypes.find({});  
   },   
 });  

Sounds pretty straight forward right? You'd expect that you would be able to use the types() function inside your template? WRONG! Instead you will that your variables are 'undefined'.

It turns the types() function is meant to be used within the body of the html ONLY.
So if you want to use the types() function from within a template, you will need to redefine it again as follows:


 Template.registerHelper("types", function() {      
   return DocTypes.find({});    
 });  

I hope this helps somebody else out there as this took me a while to figure out

Cheers!

Thursday, May 19, 2016

Meteor TypeError: undefined is not a function

In Meteor, I was adding a new mongo collection using the following code:

 export const Areas = new Mongo.collection('areas');  

The app restarted and I got the following error:

 TypeError: undefined is not a function  
   at meteorInstall.imports.api.documents.js (imports/api/documents.js:8:22)  
   at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:141:1)  
   at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:75:1)  
   at meteorInstall.server.main.js (server/main.js:2:1)  
   at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:141:1)  
   at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:75:1)  
   at C:\Users\Philip\doc-revision\.meteor\local\build\programs\server\app\app.js:240:1  
   at C:\Users\Philip\doc-revision\.meteor\local\build\programs\server\boot.js:283:10  
   at Array.forEach (native)  
   at Function._.each._.forEach (C:\Users\Philip\AppData\Local\.meteor\packages\meteor-tool\1.3.2_4\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\underscore\underscore.js:79:11)  

It turns out that the word 'collection' should have been 'Collection'. This one was difficult to spot, but I eventual found it. The following code fixes the error


 export const Areas = new Mongo.Collection('areas');  

Wednesday, May 18, 2016

Grails 2.x + Webflow + Services defined in domain classes = Fail

Environment:

  • Grails 2.5.4
  • Webflow plugin 2.1.0

I know it's been documented that you can define services inside domain classes for a Grails project. And for the most part this works, until you want to use them in a webflow.

We started noticing some very strange behaviour where the domain classes stored in flow scope started missing property values. For some apparent reason, as the user progresses through the webflow, the properties of these domain classes would reset to null!!

The fix was to remove any service class definitions inside domain classes.


Tuesday, May 3, 2016

Meteor datepicker formatting

Meteor version: 1.3.2.4
Package: rajit:boostrap3-datepicker (https://atmospherejs.com/rajit/bootstrap3-datepicker)




 Template.body.rendered=function() {  
   $('.datepicker').datepicker({  
     format: "dd/mm/yyyy"  
   });  
 }  

Monday, April 11, 2016

ReferenceError: check is not defined

Meteor version: v1.3

I was following the tutorial on the meter website found here:

https://www.meteor.com/tutorials/blaze/security-with-methods

In the tutorial they recommend checking user input using a command as follows:

check(text, String);
However, when I go to run the application, I got the error message:

Exception while invoking method 'tasks.remove' ReferenceError: check is not defined
 No where in the tutorial did it mention that you had to add the 'check' package. So running the following command solved the problem:

meteor add check

Thursday, April 7, 2016

Meteor - TypeError: Cannot call method 'config' of undefined

Following the instructions on the meteor.js tutorial site:

https://www.meteor.com/tutorials/blaze/adding-user-accounts

I ran into the following error:

TypeError: Cannot call method 'config' of undefined
 There was an import statement that I had to add to a main.js file

import '../imports/startup/accounts-config.js';

It turns out I had added the  import line into the wrong 'main.js' file.
There are 2 main.js files: One in the client folder and the other in the server folder.


Once I moved the import statement to the client version, the app started working again


'npm' is not a Meteor command

I had previously installed Meteor months ago with the intention of giving it a go, but never got around to it. Fast forward to today, I tried to reinstall Meteor using the latest installer for version 1.3. Then I proceeded to follow the tutorials where one step required me enter the command:

meteor npm install

I received the following error:

'npm' is not a Meteor command. See 'meteor --help'.

It turns out that my version of Meteor was not actually updated by the installer. To check my meteor version I used the following command:

meteor --version

Which showed me "Meteor 1.2.0.2".

Solution

To upgrade meteor, run the following command:

meteor update
Reference: https://forums.meteor.com/t/installing-meteor-1-3-with-an-existing-1-2-left-in-place/20670