-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
This is My JS Code
tasks = new SQL.Collection("tasks");
if (Meteor.isClient) {
tasks.createTable({
id: ['$number'],
text: ['$string'],
checked: ['$bool', {$default: false}],
createdAt: ['$datetime']
});
Template.body.helpers({
tasks: function () {
return tasks.select().fetch();
}
});
Template.body.events({
"submit .new-task": function (event) {
event.preventDefault();
var text = event.target.text.value;
tasks.insert({
text: text,
createdAt: new Date()
}).save();
event.target.text.value = "";
}
});
Template.task.events({
"click .toggle-checked": function () {
tasks.update({
id: this._id,
"checked": !this.checked
}).where("id = ?", this.id).save();
},
"click .delete": function () {
tasks.remove().where("id = ?", this.id).save();
}
});
}
if (Meteor.isServer) {
tasks.createTable({
id: ['$number'],
text: ['$string'],
checked: ['$bool', {$default: false}],
createdAt: ['$datetime']
}).save();
tasks.publish('Tasks', function () {
return tasks.select().save();
})
}
this is my html Code
<head>
<title>Todo List</title>
</head>
<body>
<div class="container">
<header>
<h1>Todo List</h1>
<form class="new-task">
<input type="text" name="text" placeholder="Type to add new tasks" />
</form>
</header>
<ul>
{{#each tasks}}
{{> task}}
{{/each}}
</ul>
</div>
</body>
<template name="task">
<li class="{{#if checked}}checked{{/if}}">
<button class="delete">×</button>
<input type="checkbox" checked="{{checked}}" class="toggle-checked"/>
<span class="text">{{text}}</span>
</li>
</template>
and this is the error log :
TypeError: Cannot call method 'query' of null
please help me i cant find the mistake;
thanks in
advance
Metadata
Metadata
Assignees
Labels
No labels