Textarea editor Redactor. Insert value with jQuery

我是研究僧i 提交于 2019-12-23 08:15:19

问题


Have field textarea id="tr" using HTML editor Redactor last version trying to set value of the field exactly haw it is described in API Doc :

$('#tr').redactor('insertText', 'text'); 

or

$('#tr').redactor('insertHtml', 'text');

What am I doing wrong ?


回答1:


Try the set API, which I think is a lower-level version of insertText/insertHtml.

So in your example, it should be:

$('#tr').redactor('set', 'Your text goes here');

Update: In redactor version 10 (and greater), the name of the set method was changed, as documented here:

$('#tr').redactor('code.set', 'Your text goes here');



回答2:


This code work perfectly for destroy and then update to new.

$('#redactor_subcontentid').destroyEditor();
// set it to new 
$('#redactor_subcontentid').redactor().setCode("Your Text");


来源:https://stackoverflow.com/questions/19590297/textarea-editor-redactor-insert-value-with-jquery

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!