diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-10-10 15:59:50 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-10-10 15:59:50 -0400 |
| commit | e35d5df30c8106bc1f4bfcbd1ba0094d8e6bc642 (patch) | |
| tree | 3a08b1f98211f554aa6ab49aa986ab236601f810 /public/assets/javascripts/ui/site/ProfileView.js | |
| parent | e75bf50727b3ebdd142953c09117de38d3a5b174 (diff) | |
change profile avatar
Diffstat (limited to 'public/assets/javascripts/ui/site/ProfileView.js')
| -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)); } }) |
