Skip to content

Instantly share code, notes, and snippets.

@chapel
Forked from anonymous/gist:777006
Created January 12, 2011 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chapel/777009 to your computer and use it in GitHub Desktop.
Save chapel/777009 to your computer and use it in GitHub Desktop.
this.post('#/reply', function (context) {
var fields = this.params, doc = {};
doc.content = fields['post'];
doc.datetime = new Date.now();
doc.thread_id = fields['thread_id'];
doc.type = 'post';
doc.user_id = 'chapel';
console.log(doc);
db.saveDoc(doc, {
success: function() {
this.redirect('#/thread/'+fields.thread_id);
},
error: function() {
alert('Error saving document.');
this.redirect('#/thread/'+fields.thread_id);
}
});
return false;
});
<div id="reply">
<form action="#/reply" method="POST">
<input type="hidden" name="thread_id" value="" />
<textarea name="post" cols=100 rows=10></textarea>
<p><input type="submit" value="Reply" /></p>
</form>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment