Error: No such function: only in production mode


#1

My App is running perfectly in debug mode but when I run it in production mode I get “Error: No such function: canAddMore”. Here is the JS code I have…

Template.fbRegister.helpers ({
	
	jobCount : function() {
		return Session.get("jobCount");
	},
	
	eduCount : function() {
		return Session.get("eduCount");
	},
	
	moreThanOneJob : function() {
		return Session.get('jobCount').length > 1
	},
	
	moreThanOneEdu : function() {
		return Session.get('eduCount').length > 1
	},
	
	canAddMore : function(count) {
		console.log(count)
		return count.length <= 2
	},
});

And here is the HTML code …

{{#if canAddMore jobCount}}<a class="normal-link add-job">+ Add another Job</a>{{/if}}

What am I doing wrong here?

Any help would be appreciated. Thanks.


#2

Does calling any of the other functions work? e.g moreThanOneEdu?


#3

Yes they all do. I am getting errors in the functions to which I am passing a variable from the Template.


#4

Not ideal, but as a workaround, you could try referencing jobCount from within canAddMore via Template.instance().jobCount.get() (assuming it’s a reactive var?) if the parameter is an issue.

No idea what the problem is sorry.


#5

You are missing a bunch of semi colons. It’s possible this is working in debug but is being broken by minification.


#6

You could be right. I guess I’ll have to go through all my JS files to see how many I’ve missed, fix them and try again. Thanks for that.
The silliest of things.


#7

It seems as if the last comma shouldn’t be there after canAddMore.