Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simpleprogrammer-shared/a9da2cce0d86c767b4b79159007e6708 to your computer and use it in GitHub Desktop.
Save simpleprogrammer-shared/a9da2cce0d86c767b4b79159007e6708 to your computer and use it in GitHub Desktop.
Getting Started With Meteor Tutorial (In the Cloud) 6
Items = new Meteor.Collection("items");
if (Meteor.isClient) {
Template.list.helpers({
items: function() {
return Items.find();
},
});
Template.controls.events({
'submit form': function(event) {
event.preventDefault();
var description = $(event.target).find('[id=newItem]').val();
Items.insert({description:description});
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
if(Items.find().count() == 0) {
var items = [
{ description: "Create Meteor app"},
{ description: "Buy an SSD"}
];
for(var i =0; i<items.length; i++) {
Items.insert(items[i]);
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment