Skip to content

Instantly share code, notes, and snippets.

@brianjmiller
Last active Dec 25, 2015
Embed
What would you like to do?
Backbone .save handlers
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