Last active
March 7, 2016 07:58
-
-
Save Archana-p/b6cc75ba2ef67c9cb245 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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