-
Notifications
You must be signed in to change notification settings - Fork 0
/
shawn.js
52 lines (41 loc) · 908 Bytes
/
shawn.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Text = new Meteor.Collection('text');
if (Meteor.isClient) {
Router.configure({
layoutTemplate: 'layout',
waitOn: function(){
return [
Meteor.subscribe('texts')
]
}
});
Router.map(function(){
this.route('/', {
template: 'hello'
})
});
Template.hello.greeting = function () {
return "Welcome to shawn.";
};
Template.hello.helpers({
list: function () {
return Text.find();
}
});
Template.hello.events({
'submit form': function (e, tmpl) {
e.preventDefault();
// template data, if any, is available in 'this'
var text = $(tmpl.find('input[type="text"]')).val();
console.log(text)
Text.insert({text: text});
}
});
}
if (Meteor.isServer) {
FastRender.route('/', function(){
this.subscribe('texts');
});
Meteor.publish('texts', function(){
return Text.find();
})
}