6 回答

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();
});

TA貢獻1860條經驗 獲得超8個贊
您必須將值從 suneditor 發送到 textarea,您可以這樣做:
$(window).click(function() { document.getElementById('txtEditor').value = txtEditor.getContents(); });

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>

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');

TA貢獻1821條經驗 獲得超5個贊
您只需要運行該instance.save()方法。
const instance = SUNEDITOR.create();
instance.save()

TA貢獻1833條經驗 獲得超4個贊
您需要在 if 條件中使用 isset 函數,否則會拋出錯誤。
if(isset($_POST["submit"])){
$content = $_POST["txtEditor"];
echo $content;
}
添加回答
舉報