Skip to content

Instantly share code, notes, and snippets.

@Archana-p
Last active March 7, 2016 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Archana-p/b6cc75ba2ef67c9cb245 to your computer and use it in GitHub Desktop.
Save Archana-p/b6cc75ba2ef67c9cb245 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
//upload image in description
$('#email_description').summernote({
height: 300,
onImageUpload: function(files, editor, welEditable) {
for (var i = files.length - 1; i >= 0; i--) {
sendFile(files[i], this);
}
}
});
//create record for attachment
function sendFile(file, el) {
data = new FormData();
data.append("file", file);
$.ajax({
type: "POST",
url: "/compose_mails/attachment_upload",
data: data,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
success: function(response) {
$(el).summernote('editor.insertImage', response.url.attachment_url.url, response.id);
},
error : function(error) {
alert('error');
},
complete : function(response) {
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment