Last active
December 25, 2015 21:29
-
-
Save brianjmiller/7042658 to your computer and use it in GitHub Desktop.
Backbone .save handlers
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
user.save( | |
userSaveData, | |
{ | |
success: _.bind(this._registerSuccess, this), | |
error: _.bind(this._registerError, this) | |
} | |
); | |
_registerSuccess: function () { | |
console.log("views/signUp::_registerSuccess"); | |
var prop; | |
for (prop in this._nodes) { | |
if (prop !== "indicator" && prop !== "failureReason") { | |
this._nodes[prop].val(""); | |
} | |
} | |
this._nodes.indicator.removeClass("error").addClass("success"); | |
}, | |
_registerError: function (model, xhr) { | |
console.log("views/signUp::_registerError"); | |
var msg = ""; | |
if (xhr.status === 409) { | |
msg = "account already exists"; | |
} | |
else { | |
msg = xhr.responseText + " (" + xhr.status + ")"; | |
} | |
this._registerFailure(msg); | |
}, | |
_registerFailure: function (reason) { | |
console.log("views/signUp::_registerFailure"); | |
this._nodes.indicator.removeClass("success").addClass("error"); | |
this._nodes.failureReason.html(reason); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment