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 ?
If you are using an old version of redactor, you can 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 (2015-04-21): In redactor v2, the name of the set method was changed:
$('#tr').redactor('code.set', 'Your text goes here');
Another Update (2020-04-20): In their latest version, Imperavi changed their syntax and provided two ways to achieve this solution:
const editor = $R('#tr');
editor.source.setCode('Your text goes here');
or
$R('#tr', 'source.setCode', 'Your text goes here');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With