Skip to content

Instantly share code, notes, and snippets.

@chintanparikh
Created March 7, 2013 21:17
Show Gist options
  • Save chintanparikh/5111872 to your computer and use it in GitHub Desktop.
Save chintanparikh/5111872 to your computer and use it in GitHub Desktop.
Template.items.items = function()
{
return Items.find({});
};
Template.new.events = {
'keyup #new-item': function (e) {
if (e.keyCode === 13)
{
var new_item = $("#new-item").val();
if (new_item != '')
Items.insert({name: new_item});
$("#new-item").val("");
}
}
}
Template.item.events({
'click .close': function()
{
var id = "#" + this['_id'];
$(id).fadeOut('slow', function()
{
Items.remove(this);
});
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment