mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 04:16:37 -04:00
27 lines
No EOL
690 B
JavaScript
27 lines
No EOL
690 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
|
|
, body: body
|
|
, user_id: Meteor.user()._id
|
|
, 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');
|
|
Router.navigate('posts/'+postId, {trigger: true});
|
|
}
|
|
}; |