我想在dropzone中包含textara(tynimce),但是当我发送时,这最后给我一个空值。
请查看:https://jsfiddle.net/0qoejLo2/8/
this.on("success", function(file,xhr, reponse){
tinymce.activeEditor.execCommand('mceInsertContent', false, 'msg');
没有工作回复这个
Array
(
[file] => Array
(
[name] => drop.zip
[type] => application/zip
[tmp_name] => /tmp/phpLl2BoZ
[error] => 0
[size] => 20848
)
)
$_POST:
Array
(
[email_de] => tata@titi.fr
[a] => titi@toto.com
[sujet] => bateau
[null] =>
[msg] =>
)
如果重新加载页面帖子,我必须检索textearea中msg标记中的消息内容
[null] =>
[msg] => <p>hghgjdmsg<br data-mce-bogus="1"></p>
答案 0 :(得分:2)
尝试使用init函数中的以下事件挂钩(您配置DZ的位置)替换“success”事件挂钩。
this.on("sending", function(file, xhr, formData){
formData.append("msg", tinymce.activeEditor.getContent());
});
如果我没记错的话,TinyMCE会删除textarea并将其替换为非形式标记,因此Dropzone的自动字段提交将错过其内容。您需要明确告诉Dropzone它需要发送TinyMCE编辑器的内容。
Dropzone的“发送”事件发布在发布数据之前。之后会调用“success”事件,因此尝试发送编辑器的内容是没用的。
Dropzone文档中的更多信息:http://www.dropzonejs.com/#event-sending