CLEditor动态添加文本

我正在使用CLEditor用于我正在开发的网站。 我正在尝试使用jQuery将动态文本添加到textarea。 通常我会使用类似的东西:

$('#myText').val('Here some dynamic text'); 

但这只适用于CLEditor。 禁用CLEditor时,它可以正常工作,再次启用它,文本就会消失。 我试着在网站上寻找解决方案,但我找不到任何解决方案。 最近有人有同样的问题吗?

提前致谢。

 $("#input").cleditor({width:500, height:250,updateTextArea:function (){....}}) 

当调用textarea的blur方法时,CLEditor更新iFrame内容:

 //make CLEditor $(document).ready(function() { $('#text').cleditor(); }); //set value $('#text').val('new text data').blur(); 

我遇到了同样的问题,最后在评论中发现了一些有用的东西,所以这就是我所拥有的; 希望这会对未来的某些人派上用场。

 // initializing the cleditor on document ready var $editor = $('#description').cleditor() 

然后当我得到一些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('testing'); // update cleditor with the latest html contents $editor.updateFrame(); 

例如,如果对某人有帮助,您可以使用它。

情况,我需要更改下拉字段值,以更改cleditor的内容。

  

change_dimmensions_table.php:

  0) { while ( $row = mysql_fetch_object( $result)) { $html = $row->html_content; } } if ( ! empty( $html)) { echo $html; } } ?> 

我知道这是一个迟到的答案,但是:

 $('#myText').cleditor()[0].execCommand('inserthtml','Here some dynamic text'); 

如果你问我的话,这真的是最简单的答案。 另一个简单的答案是弗朗西斯·刘易斯上面给出的。

execCommand很有魅力,但它在IE中不起作用,val()。blur()是可靠的