diff options
Diffstat (limited to 'public/assets/js/lib/views/details/commentform.js')
| -rw-r--r-- | public/assets/js/lib/views/details/commentform.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/public/assets/js/lib/views/details/commentform.js b/public/assets/js/lib/views/details/commentform.js new file mode 100644 index 0000000..30671f2 --- /dev/null +++ b/public/assets/js/lib/views/details/commentform.js @@ -0,0 +1,33 @@ +var CommentForm = FormView.extend({ + + el: "#comment_form", + + events: { + }, + + action: "/api/thread/1/comment", + + initialize: function(){ + this.__super__.initialize.call(this) + this.template = this.$(".template").html() + this.$comment = this.$("[name=comment]") + }, + + load: function(thread){ + this.action = "/api/thread/" + thread.id + "/comment" + }, + + validate: function(){ + var errors = [] + var comment = $("[name=comment]").val() + if (! comment || ! comment.length) { + errors.push("Please enter a comment.") + } + return errors.length ? errors : null + }, + + success: function(comment){ + this.prependComment(comment) + this.$("[name=comment]").val("") + } +})
\ No newline at end of file |
