Hi,
Im relatively new to meteor and javascript. Im trying to have my Mongo Collection fill a drop down list, but it doesnt seem to be working:
In my server folder I have the following:
/server/publications/publications.js
import { Meteor } from 'meteor/meteor'
Meteor.publish('states', function() {
return States.find({});
});
/server/collections/collections.js
import { Mongo } from 'meteor/mongo';
States = new Mongo.Collection('states');
and
In my client-side template I have the following:
Template.AddCity.onCreated(function () {
var self = this;
self.autorun(function() {
//Subscribe to all clubs
self.subscribe("states");
});
});
Template.AddCity.onRendered(function () {
});
Template.AddCity.helpers({
state (){
return States.find({});
},
});
and the html template:
<template name="AddCity">
<form >
<div style="border-style:solid;border-color:black">
<h3>Add City</h3>
<hr style="color:black">
<select id="statename">
<option>Please Select State</option>
{{#each state}}
<option value={{statecode}}>{{statename}}</option>
{{/each}}
</select>
<br>
<br>
<input id="addcitynametext" type="text" name="cname" placeholder="City Name"><br>
<br>
<input id="addcitybutton" class="btn" type="submit" value="Submit">
</div>
<br>
</form>
</template>
When I go to fetch the states in the Developer Console, I get an Uncaught reference error that States cannot be found. Any help would be appreciated;
thanks,
Sabin