24 lines
793 B
JavaScript
24 lines
793 B
JavaScript
|
$(function() {
|
||
|
var $upload_file = $('.upload_file');
|
||
|
$('.upload_file').fileupload({
|
||
|
url: '/upload_avatar.json?source_type=' + $('.upload_file').attr('data-source-type') +
|
||
|
'&source_id=' + $('.upload_file').attr('data-source-id'),
|
||
|
formData: function(form) {
|
||
|
var data = form.serializeArray();
|
||
|
var auth = null;
|
||
|
for(var key in data){
|
||
|
if(data[key].name == "authenticity_token"){
|
||
|
auth = data[key];break;
|
||
|
}
|
||
|
}
|
||
|
return [auth];
|
||
|
},
|
||
|
done: function(e, data) {
|
||
|
var imgSpan = jQuery('#avatar_image');
|
||
|
imgSpan.attr({
|
||
|
"src": data.result.text ? data.result.text() : data.result
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
});
|