var CommentForm = 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(thread){ this.action = "/api/thread/" + thread.id + "/comment" }, focus: function(){ this.$el.addClass('focused') }, validate: function(){ var errors = [] var comment = $("[name=comment]").val() var files = this.$("[name=files]").val() if ((! comment || ! comment.length) && ! files) { errors.push("Please enter a comment or add some files.") } return errors.length ? errors : null }, success: function(){ window.location.reload() } })