socialforge/public/javascripts/jq-upload/upload.js

24 lines
793 B
JavaScript
Raw Normal View History

$(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
});
}
});
});