Redactor text editor. Insert value using jQuery

There is a textarea id="tr" field using the HTML editor. The latest version of Redactor trying to set the field to exactly haw, this is described in the Doc API:

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

or

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

What am I doing wrong?

+7
source share
2 answers

Try installing the API , which I think is a lower level insertText / insertHtml .

So in your example, this should be:

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

Update . In version 10 (and later) editor, the name of the dialing method has been changed as described here :

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

This code is perfect for destroying and then upgrading to a new one.

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

Source: https://habr.com/ru/post/956712/


All Articles