我以前从未遇到过这种情况,这就是为什么我来看看是否有人可以阐明原因或造成这种情况的原因。
基本上,我使用以下 html javascript 在 Tinymce 编辑器中调用:
<script type="text/javascript">
jQuery(document).ready(function() {
tinymce.init({
selector: "#content",
theme: "modern",
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste imagetools Customlayouts Customshortcodes, autoresize responsivefilemanager"
],
toolbar: "Customlayouts Customshortcodes | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist | link responsivefilemanager image media | code fullscreen",
image_advtab: true ,
relative_urls: false,
external_filemanager_path:"http://<?php echo $_SERVER['HTTP_HOST']; ?>/Libs/filemanager/",
filemanager_title:"Responsive Filemanager" ,
external_plugins: { "filemanager" : "/Libs/filemanager/plugin.min.js"}
});
});
</script>
<div class="form-group">
<label for="content" class="col-sm-2 control-label">Page Content</label>
<div class="col-sm-9">
<textarea id="content" name="content"></textarea>
</div>
</div>
所以问题是,当您第一次提交表单时,它不会发送任何内容,如下所示:
'type' => string 'sendform' (length=8)
'name' => string '' (length=0)
'title' => string '' (length=0)
'slug' => string '' (length=0)
'tags' => string '' (length=0)
'description' => string '' (length=0)
'content' => string '' (length=0)
'islive' => string 'false' (length=5)
但是,如果我再次单击提交按钮而不执行任何操作,它就会发送如下所示的内容:
'type' => string 'sendform' (length=8)
'name' => string '' (length=0)
'title' => string '' (length=0)
'slug' => string '' (length=0)
'tags' => string '' (length=0)
'description' => string '' (length=0)
'content' => string '<p>sdfsdfsdf</p>' (length=16)
'islive' => string 'false' (length=5)
我正在使用ajax发送表单,这很可能是问题所在。 这是我的 jquery 提交:
jQuery(document).ready(function($){
$('#addnewpage').on('submit', function(e){
e.preventDefault();
$.ajax({
url: "/Applications/Controllers/Pages/ajax-pages.php",
type: "POST",
data: new FormData(this),
contentType: false,
cache: false,
processData:false,
success: function(data){
if(data === 'success'){
window.location.href = "/Control-Panel/Pages/Manage/?success=added";
} else {
$('#ubl-fail').slideUp(300);
$('#ubl-fail').html(data);
$('#ubl-fail').delay(350).slideDown(300);
window.scrollTo(0, 0);
}
}
});
});
});
我不明白为什么会发生这种情况,我正在检查控制台日志以查看是否出现任何错误,但没有任何错误。 我在 html 或 php 方面也没有错误。 特别是考虑到目前在 php 方面我只是这样做:
var_dump($_POST);
无论如何,这就是问题所在,如果有人能够解释为什么会发生这种情况,我将非常感激。
谢谢
最佳答案
我也遇到了同样的问题。结果我所要做的就是在提交之前添加tinyMCE.triggerSave()。
$('#addnewpage').on('submit', function(
tinyMCE.triggerSave();
$('form#document-form').submit();
});
关于javascript - 使用 Tinymce 文本编辑器首次发送时内容文本区域为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44197332/