Created
September 1, 2013 10:11
-
-
Save anonymous/6403481 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<title>todo</title> | |
</head> | |
<body> | |
<div class="wrapper"> | |
{{> list}} | |
{{> addTodo}} | |
</div> | |
</body> | |
<template name="list"> | |
<h1>Todo</h1> | |
<ul> | |
{{#each todoList}} | |
{{> todoItem}} | |
{{/each}} | |
</ul> | |
</template> | |
<template name="todoItem"> | |
<li><input type="checkbox" class="done" {{#if done}}checked="checked"{{/if}}"></input> {{title}} </li> | |
</template> | |
<template name="addTodo"> | |
<input type="text" id="newTitle"></input> <input type="button" class="addOff btn btn-primary" value="Add"></input> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<title>todo</title> | |
</head> | |
<body> | |
<div class="wrapper"> | |
{{> list}} | |
{{> addTodo}} | |
</div> | |
</body> | |
<template name="list"> | |
<h1>Todo</h1> | |
<ul> | |
{{#each todoList}} | |
{{> todoItem}} | |
{{/each}} | |
</ul> | |
</template> | |
<template name="todoItem"> | |
<li><input type="checkbox" class="done" {{#if done}}checked="checked"{{/if}}"></input> {{title}} </li> | |
</template> | |
<template name="addTodo"> | |
<input type="text" id="newTitle"></input> <input type="button" class="addOff btn btn-primary" value="Add"></input> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TodoItems = new Meteor.Collection("todoitems"); | |
if (Meteor.isClient) { | |
Template.list.todoList = function () { | |
return TodoItems.find().fetch(); | |
}; | |
Template.addTodo.events({ | |
'click .addOff': function () { | |
//alert("Creating new todo: " + $("#newTitle").val()); | |
var newTodo = { | |
title: $("#newTitle").val(), | |
done: false | |
}; | |
TodoItems.insert(newTodo); | |
} | |
}); | |
Template.todoItem.events({ | |
'change .done': function (a, b) { | |
TodoItems.update(this._id, {$set: {done: true}}); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment