我之前从未遇到过这个问题,这就是为什么我来看看是否有人可以解释为什么或导致这种情况的原因。
基本上我使用以下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);
无论如何这就是问题,如果有人能说清楚为什么会这样,我会非常感激。
由于
答案 0 :(得分:1)
我有同样的问题。事实证明,我所要做的就是在提交之前添加tinyMCE.triggerSave()。
$('#addnewpage').on('submit', function(
tinyMCE.triggerSave();
$('form#document-form').submit();
});
答案 1 :(得分:-1)
添加这个脚本...
<script type="text/javascript" src="tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({mode : "specific_textareas", editor_selector : "myTextEditor", theme: "modern", theme_advanced_fonts : "Andale Mono=andale mono,times; "+ "Arial=arial,helvetica,sans-serif; "+ "Arial Black=arial black,avant garde; "+ "Book Antiqua=book antiqua,palatino; "+ "Comic Sans MS=comic sans ms,sans-serif; "+ "Courier New=courier new,courier; "+ "Georgia=georgia,palatino; "+ "Helvetica=helvetica; "+ "Impact=impact,chicago; "+ "Symbol=symbol; "+ "Tahoma=tahoma,arial,helvetica,sans-serif; "+ "Terminal=terminal,monaco; "+ "Times New Roman=times new roman,times; "+ "Trebuchet MS=trebuchet ms,geneva; "+ "Verdana=verdana,geneva; "+ "Webdings=webdings; "+ "Wingdings=wingdings,zapf dingbats", plugins: [ "advlist autolink lists link image charmap print preview hr anchor pagebreak", "searchreplace wordcount visualblocks visualchars code fullscreen", "insertdatetime media nonbreaking save table contextmenu directionality", "emoticons template paste textcolor colorpicker textpattern" ], toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image", toolbar2: "fontselect | forecolor backcolor emoticons", image_advtab: true, templates: [ {title: 'Test template 1', content: 'Test 1'}, {title: 'Test template 2', content: 'Test 2'} ]});
</script>