var LoginView = FormView.extend({ el: "#login", action: "/api/login", method: "put", initialize: function(opt){ this.__super__.initialize.call(this) $("body").removeClass("loading") this.$("[name=username]").focus() }, showErrors: function(err){ $(".errors").show().css({ opacity: 1 }).html("Bad username/password combo") }, success: function(data){ console.log("LOGGED IN?", data) if (data.user) { auth.set_user(data.user) } else { this.showErrors() return } if (data.returnTo) { console.log(data.returnTo) window.location.href = data.returnTo } else { window.location.href = "/index" } }, })