diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-08 02:18:49 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-08 02:18:49 +0100 |
| commit | bbbd8bbab8737f5067c85376daf79cd8a5a9c4cb (patch) | |
| tree | 844d1385d7b88623eee3c2ea2c420280006ad349 /public/assets/js/lib/views/details/commentform.js | |
| parent | e4e0cf21a31b74d5ee1e6d45b343ea60ed44f372 (diff) | |
| parent | df674eef8e20c43426c0af5aa3d1a09b5e24c58a (diff) | |
merge
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 |
