我如何使用InsertHtml?

问题描述 投票:1回答:1

我如何在内容中插入HTML代码?

image ckeditor

此方法不插入html代码:

CKEDITOR.instances['update_content'].setData(info_content);

我试过了:

CKEDITOR.instances['update_content'].editable().insertHtml('<p>This is a new paragraph.</p>');

但是我得到了错误:

ckeditor.js?v=3:407 Uncaught TypeError: Cannot read property 'checkReadOnly' of undefined
    at ckeditor.js?v=3:407
    at $.insertHtml (ckeditor.js?v=3:377)
    at HTMLButtonElement.<anonymous> (shop:3750)
    at HTMLButtonElement.dispatch (jquery.min.js:3)
    at HTMLButtonElement.r.handle (jquery.min.js:3)

我需要动态内容,我需要在每个点击按钮的CKEditor内容中更改HTML代码。

ckeditor4.x
1个回答
0
投票

你不应该在insertHtml之后使用editable(),而是应该使用以下代码:

CKEDITOR.instances['update_content'].insertHtml('<p>This is a new paragraph.</p>');
© www.soinside.com 2019 - 2024. All rights reserved.