Есть две textarea, summernote запускается следующим образом
$('textarea').summernote({
onImageUpload: function(files, editor, $editable) {
sendFile(files[0],editor,$editable);
},
height: 300, // set editor height
minHeight: null, // set minimum height of editor
maxHeight: null, // set maximum height of editor
focus: true, // set focus to editable area after initializing summernote
});
Загрузка файла
function sendFile(file,editor,welEditable) {
data = new FormData();
data.append("file", file);
$.ajax({
url: "fileupload.php",
data: data,
cache: false,
contentType: false,
processData: false,
type: 'POST',
success: function(data) {
$('textarea').summernote("insertImage", data, 'filename');
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus+" "+errorThrown);
}
});
}
Проблема в том что если на странице несколько textarea, вставка файла происходит не всегда в нужную textarea.