javascript TinyMCE 不发送值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5807156/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
TinyMCE not sending value
提问by SamarLover
Hi All
It's the first time I've used Tiny Mce and I have a problem. Please Help
大家好
这是我第一次使用 Tiny Mce,但遇到了问题。请帮忙
The editor works fine in editing but when I click submit nothing is sent from the textarea input
编辑器在编辑时工作正常,但是当我点击提交时,textarea 输入没有发送任何内容
Here is the code:
这是代码:
<textarea name='proddesc' class='text_area' id='elm1' /></textarea>
I'm using jQuery, this is the code:
我正在使用 jQuery,这是代码:
$('#addprod').submit(function(){
$("#addprodmsg").hide();
$.post('addprod.php', $("#addprod").serialize(),
function(data){
$("#addprodmsg").html(data);
});
$("#addprodmsg").show();
return false;
});
The Php Code is:
PHP代码是:
foreach($_POST as $key){echo "<script>alert('$key')</script>";}
Everything alerts a value but the textarea is not alerting anything.
一切都会提醒一个值,但 textarea 没有提醒任何东西。
Also, when I disabled TinyMce and submit the form everything is ok.
此外,当我禁用 TinyMce 并提交表单时,一切正常。
2 - I'm using the rtl direction and I have this photo:
2 - 我正在使用 rtl 方向,我有这张照片:
http://www.image-upload.net/images/mly8a68ufs0mdeky6low.jpg
http://www.image-upload.net/images/mly8a68ufs0mdeky6low.jpg
Look At Style :(
看风格:(
Thank You
谢谢
回答by Thariama
It is necessary to update the textareas content with the content of the editors iframe (tinymce uses an editable iframe like most rtes). In order to achieve this you need to call tinymce.get('elm1').save();
before you submit.
有必要使用编辑器 iframe 的内容更新 textareas 内容(tinymce 像大多数 rtes 一样使用可编辑的 iframe)。为了实现这一点,您需要tinymce.get('elm1').save();
在提交之前调用。
You can also grab the editors content using tinymce.get('elm1').getContent();
and sent this.t
您还可以使用tinymce.get('elm1').getContent();
并发送 this.t来获取编辑器内容
回答by Rodion
function SubmitForm() {
tinyMCE.triggerSave();
$('#submit-form-training-materials').submit();
}