问题
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