6 回答
![?](http://img1.sycdn.imooc.com/5458506b0001de5502200220-100-100.jpg)
TA贡献1898条经验 获得超8个赞
完整代码
const description = SUNEDITOR.create((document.getElementById('description')),{
buttonList: [
['undo', 'redo'],
['bold', 'underline', 'italic'],
['removeFormat'],
['outdent', 'indent'],
['align', 'list'],
['table'],
['fullScreen', 'showBlocks']
],
lang: SUNEDITOR_LANG['pl']
});
$(window).click(function() {
document.getElementById('description').value = description.getContents();
});
![?](http://img1.sycdn.imooc.com/545868330001e54e02200220-100-100.jpg)
TA贡献1860条经验 获得超8个赞
您必须将值从 suneditor 发送到 textarea,您可以这样做:
$(window).click(function() { document.getElementById('txtEditor').value = txtEditor.getContents(); });
![?](http://img1.sycdn.imooc.com/54584cfb0001308402200220-100-100.jpg)
TA贡献1884条经验 获得超4个赞
无需为此编写任何 js 代码,只需将您的文本/内容放在 textarea 标记之间,就像:
<textarea id="txtEditor" name="txtEditor" style="display:none;">Here is your text</textarea>
OR
<textarea id="txtEditor" name="txtEditor" style="display:none;">
<?= $content; ?>
</textarea>
![?](http://img1.sycdn.imooc.com/545861f00001be3402200220-100-100.jpg)
TA贡献1817条经验 获得超14个赞
// Gets the suneditor's context object. Contains settings, plugins, and cached element objects
editor.getContext();
// Gets the contents of the suneditor
// onlyContents {Boolean}: Return only the contents of the body without headers when the "fullPage" option is true
editor.getContents(onlyContents: Boolean);
// Gets only the text of the suneditor contents
editor.getText();
// Change the contents of the suneditor
editor.setContents('set contents');
![?](http://img1.sycdn.imooc.com/54586425000103f602200220-100-100.jpg)
TA贡献1821条经验 获得超4个赞
您只需要运行该instance.save()方法。
const instance = SUNEDITOR.create();
instance.save()
![?](http://img1.sycdn.imooc.com/54584d080001566902200220-100-100.jpg)
TA贡献1833条经验 获得超4个赞
您需要在 if 条件中使用 isset 函数,否则会抛出错误。
if(isset($_POST["submit"])){
$content = $_POST["txtEditor"];
echo $content;
}
添加回答
举报