mirror of
https://github.com/vale981/Vulcan
synced 2025-03-08 11:01:38 -05:00
29 lines
704 B
JavaScript
29 lines
704 B
JavaScript
Template.submit.events = {
|
|
'click input[type=submit]': function(event){
|
|
event.preventDefault();
|
|
if(!Meteor.user()) throw 'You must be logged in.';
|
|
|
|
var title= $('#title').val();
|
|
var url = $('#url').val();
|
|
var body = $('#body').val();
|
|
|
|
var postId = Posts.insert({
|
|
headline: title
|
|
, url: url
|
|
, submitter: Meteor.user().username
|
|
, submitted: new Date().getTime()
|
|
, votes: 0
|
|
, comments: 0
|
|
});
|
|
var post = Posts.findOne(postId);
|
|
|
|
Meteor.call('voteForPost', post);
|
|
|
|
Session.set('selected_post', post);
|
|
Session.set('state', 'view_post');
|
|
}
|
|
};
|
|
|
|
Template.submit.show = function(){
|
|
return Session.equals('state', 'submit');
|
|
};
|