diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-10-10 16:00:01 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-10-10 16:00:01 -0400 |
| commit | b35bda803440233b68389603bbaced53f8bb18ba (patch) | |
| tree | d1ca48fb651307799cb33cb766b0988a5613043f /public/assets/javascripts/ui/site | |
| parent | 12b7f63b9d6687b3177bf30a212fdf856864b4f5 (diff) | |
| parent | 8990307ff8f90007b59cf778d2b3da0372dedf14 (diff) | |
merge
Diffstat (limited to 'public/assets/javascripts/ui/site')
| -rw-r--r-- | public/assets/javascripts/ui/site/ProfileView.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/public/assets/javascripts/ui/site/ProfileView.js b/public/assets/javascripts/ui/site/ProfileView.js index 76d733c..8471abc 100644 --- a/public/assets/javascripts/ui/site/ProfileView.js +++ b/public/assets/javascripts/ui/site/ProfileView.js @@ -21,6 +21,25 @@ var ProfileView = View.extend({ }, uploadAvatar: function(){ + var fd = new FormData(), hasCSRF = false + var files = this.$("#profile_avatar")[0].files + if (! files.length) return + + fd.append("avatar", files[0]); + fd.append("_csrf", $("[name=_csrf]").val()) + + var request = $.ajax({ + url: "/api/profile", + type: "put", + data: fd, + dataType: "json", + processData: false, + contentType: false, + }) + + request.done($.proxy(function (response) { + window.location.href = "/profile" + }, this)); } }) |
