使用Ueditor时,需要将内容回填到编辑框,但是会报错,报这个错误的原因在于:
在执行setContent()函数的时候,Ueditor还没有初始化好,所以需要等Ueditor初始化好后在调用setContent()函数,例如:
var gContent = UE.getEditor(id,{initialFrameHeight:240,autoHeightEnabled:false,elementPathEnabled : false,toolbars: [['bold', 'italic', 'underline', 'fontborder','fontfamily', 'fontsize', 'strikethrough','removeformat', 'formatmatch','forecolor', 'backcolor', 'selectall', 'cleardoc', '|', 'lineheight', '|','justifyleft', 'justifycenter', 'justifyright', 'justifyjustify','indent','link', 'unlink','insertvideo','insertimage']]});实例化后直接调用:
gContent.setContent(m.options.content);
这样就会报上述错误,需这样:
gContent.ready(function(){ gContent.setContent(m.options.content); });