我正在使用CLEditor用于我正在开发的网站.我正在尝试使用jQuery将动态文本添加到textarea.通常我会使用类似的东西:
$('#myText').val('Here some dynamic text');
Run Code Online (Sandbox Code Playgroud)
但这只适用于CLEditor.禁用CLEditor时,它可以正常工作,再次启用它,文本就会消失.我试着在网站上寻找解决方案,但我找不到任何解决方案.最近有人有同样的问题吗?
提前致谢.
ver*_*bug 24
当调用textarea的模糊方法时,CLEditor更新iFrame内容:
//make CLEditor
$(document).ready(function() {
$('#text').cleditor();
});
//set value
$('#text').val('new text data').blur();
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题,最后在评论中发现了一些有用的东西,所以这就是我所拥有的; 希望这会对未来的某些人派上用场.
// initializing the cleditor on document ready
var $editor = $('#description').cleditor()
Run Code Online (Sandbox Code Playgroud)
然后当我得到一些html并需要动态插入到cleditor中时,这是我使用的:
// update the text of the textarea
// just some simple html is used for testing purposes so you can see this working
$('#description').val('<strong>testing</strong>');
// update cleditor with the latest html contents
$editor.updateFrame();
Run Code Online (Sandbox Code Playgroud)
$("#input").cleditor({width:500, height:250,updateTextArea:function (){....}})
Run Code Online (Sandbox Code Playgroud)