如何使用内联TinyMCE编辑器提交表单内容而无需输入


How do you submit form content without inputs with inline TinyMCE editor?

文档中是这样告诉你的。

  <form method="post" action="process.php">
    <div class="wysiwyg">Click here to edit the first section of content!</div>
    <input type="submit">
  </form>

然后在文档的头部:

tinymce.init({ selector: '.wysiwyg',
        inline: true,
etc...

但是我需要为div的内容分配一个名称,以便我的php处理页面可以获得内容。我该怎么做呢?

我试图更改到get方法,它似乎使用"mce_0"作为名称。

尝试手动执行,例如,为wysiwyg添加id

<div id="my-wysiwyg" class="wysiwyg">Click here to edit the content!</div>

则获取值

var txt = $('#my-wysiwyg').html();

然后手工发一篇文章

$.post('my.php', {wysiwyg: txt}, function onSuccess(response){
  console.log(response);
});

然后,在你的php中,你会得到一个name wysiwyg。这只是一个说明性的例子,告诉你如何做到这一点,适应你的环境。

看看这个。希望能有所帮助