diff options
Diffstat (limited to 'public/assets/javascripts/ui/EditProfileModal.js')
| -rw-r--r-- | public/assets/javascripts/ui/EditProfileModal.js | 51 |
1 files changed, 13 insertions, 38 deletions
diff --git a/public/assets/javascripts/ui/EditProfileModal.js b/public/assets/javascripts/ui/EditProfileModal.js index de8a8be..5b79a31 100644 --- a/public/assets/javascripts/ui/EditProfileModal.js +++ b/public/assets/javascripts/ui/EditProfileModal.js @@ -1,48 +1,23 @@ -var EditProfileModal = ModalView.extend({ +var EditProfileModal = ModalFormView.extend({ el: ".mediaDrawer.editProfile", - action: "/project/edit", + action: "/api/profile", - events: { - "submit form": "submit" - }, - - initialize: function(){ - this.$form = this.$("form") - this.$errors = this.$(".errors") - this.$errorList = this.$(".errorList") - }, - - reset: function(){ - this.$("input").not("[type='submit']").not("[type='hidden']").val("") - }, - load: function(){ this.reset() - this.show() + $.get("/api/profile", $.proxy(function(data){ + console.log(data) + + for (var i in data) { + this.$("[name='" + i + "']").val(data[i]) + } + + this.show() + }, this)) }, - submit: function(e){ - e.preventDefault() - - this.$errors.hide(); - this.$errorList.empty() - - var fields = this.$form.serializeArray() - - var request = $.post(this.action, $.param(fields)); - request.done($.proxy(function (response) { - if (response.error) { - this.$errors.show(); - for (var key in response.error.errors) { - this.$errorList.append('<div>' + response.error.errors[key].message + '</div>'); - } - return - } - else { - window.location.href = "/profile" - } - }, this)); + success: function(){ + window.location.href = "/profile" } }) |
