diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-11 10:04:14 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-11 10:04:14 +0100 |
| commit | 242eed0093c59047033c286d7a14608d0096b125 (patch) | |
| tree | 71fddb93c5f2c65eb9a3b0a628b2b879eba0007c /public/assets/js/lib/views/details/editcomment.js | |
| parent | c06f440e4a41853fc30ff5b231c68bd766ba96fa (diff) | |
comment edit form
Diffstat (limited to 'public/assets/js/lib/views/details/editcomment.js')
| -rw-r--r-- | public/assets/js/lib/views/details/editcomment.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/public/assets/js/lib/views/details/editcomment.js b/public/assets/js/lib/views/details/editcomment.js new file mode 100644 index 0000000..1e1474f --- /dev/null +++ b/public/assets/js/lib/views/details/editcomment.js @@ -0,0 +1,42 @@ +var EditCommentForm = FormView.extend({ + + el: "#comment_form", + + events: { + "focus textarea": 'focus', + }, + + action: "", + + initialize: function(){ + this.__super__.initialize.call(this) + this.template = this.$(".template").html() + this.$comment = this.$("[name=comment]") + }, + + load: function(id){ + this.action = "/api/comment/" + id + $.get(this.action, function(data){ + console.log(data) + this.$comment.val(data.comment.comment).focus() + $("body").removeClass("loading") + }.bind(this)) + }, + + focus: function(){ + this.$el.addClass('focused') + }, + + 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(data){ + window.location.href = "/details/" + data.comment.id + } +})
\ No newline at end of file |
