var ComposeView = FormView.extend({ el: "#compose", events: { }, action: "", initialize: function(){ this.__super__.initialize.call(this) this.template = this.$(".template").html() }, load: function(username){ this.$("[name=username]").val(sanitize(username)) $("body").removeClass('loading') }, validate: function(){ var errors = [] var username = $("[name=username]").val() var message = $("[name=message]").val() if (! username || ! username.length) { errors.push("Please enter who this message is going to.") } if (! message || ! message.length) { errors.push("Please enter your message.") } return errors.length ? errors : null }, success: function(){ window.location.reload() } })