-
-
Save ireneyiu/2d3e5de3782282ade362 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wfApp.settings.PasswordView = function(opts) { | |
this.model = opts.model; // pass in our Password object | |
this.$el = $(opts.el); | |
this.$inputCurrent = this.$el.find(opts.inputCurrent); | |
this.$inputNew = this.$el.find(opts.inputNew); | |
this.submitUrl = this.$el.attr('action'); | |
}; | |
wfApp.settings.PasswordView.prototype.submit = function(e) { | |
e.preventDefault(); | |
var params = this.$el.serializeArray(); | |
this.model = $.extend(this.model, params); | |
var validationResult = this.model.validate(); // get the validation result from Password | |
if (!validationResult.valid) { | |
this.$inputNew.val("").first().focus(); | |
this.showSubmitMessage(this.$el, validationResult.errors, "failure", 3000); | |
} else { | |
this.$el.find("input").attr("disabled", true); | |
this.showSubmitMessage(this.$el, "Saving..."); | |
$.post(this.submitUrl, params) | |
.then(this.processResponse.bind(this)) | |
.done(this.submitSuccess.bind(this)) | |
.fail(this.submitFail.bind(this)); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment