Javascript 雅虎YUI 2-富文本编辑器-can';t让setEditorHTML方法工作,什么';怎么了?

Javascript 雅虎YUI 2-富文本编辑器-can';t让setEditorHTML方法工作,什么';怎么了?,javascript,editor,yui,yahoo,rtf,Javascript,Editor,Yui,Yahoo,Rtf,今天,我第一次看到了yui2富文本编辑器。(http://developer.yahoo.com/yui/editor/) 我的网站主要使用Java服务器页面 我希望能够将编辑器文本区域中的文本设置为以前提交的值。例如,当用户在编辑器中输入文本后提交页面时,该文本可能会保存在数据库中以供将来使用。然后,我将从数据库调用该值,并将编辑器设置为在该点显示该值,以便用户可以进行修改 我在API文档中找到了一个名为setEditorHTML()的方法,但由于某种原因,我无法让它工作 这是我一直在玩的测试

今天,我第一次看到了
yui2富文本编辑器
。(http://developer.yahoo.com/yui/editor/)

我的网站主要使用Java服务器页面

我希望能够将编辑器文本区域中的文本设置为以前提交的值。例如,当用户在编辑器中输入文本后提交页面时,该文本可能会保存在数据库中以供将来使用。然后,我将从数据库调用该值,并将编辑器设置为在该点显示该值,以便用户可以进行修改

我在API文档中找到了一个名为
setEditorHTML()
的方法,但由于某种原因,我无法让它工作

这是我一直在玩的测试代码。我正在Firefox中测试

我不明白为什么
setEditorHTML
方法不起作用……有人能帮我吗?

<html>

<head>

<% String editorText = (String)session.getAttribute("editorText"); %>


<!-- Individual YUI CSS files -->
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.9.0/build/assets/skins/sam/skin.css">
<!-- Individual YUI JS files -->
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>

<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/element/element-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/container/container_core-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/menu/menu-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/button/button-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/dragdrop/dragdrop-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/slider/slider-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/colorpicker/colorpicker-min.js"></script>

<script type="text/javascript" src="Yahoo-YUI-editor/editor-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/layout/layout-min.js"></script>


<script language="javascript">
var myEditor = new YAHOO.widget.Editor('msgpost', {
    height: '300px',
    width: '522px',
    dompath: false, //Turns on the bar at the bottom
    animate: false, //Animates the opening, closing and moving of Editor windows
    handleSubmit: true
});

myEditor.render();

<% if(editorText != null) {
     out.print("myEditor.setEditorHTML(\""+editorText+"\");");         
       }
%>

</script>

</head>

<body class="yui-skin-sam">

<form name="editor" action="YahooEditor.jsp" method="post">
<textarea name="msgpost" id="msgpost" cols="50" rows="10"></textarea>
<input type="submit" value="submit"/>
</form>
</body>
</html>

var myEditor=newyahoo.widget.Editor('msgpost'{
高度:“300px”,
宽度:“522px”,
dompath:false,//打开底部的栏
animate:false,//为编辑器窗口的打开、关闭和移动设置动画
handleSubmit:对
});
myEditor.render();

编辑器渲染时有一段时间您无法访问
setEditorHTML
。试试这个:

var myEditor = new YAHOO.widget.Editor('msgpost', {
    height: '300px',
    width: '522px',
    dompath: false, //Turns on the bar at the bottom
    animate: false, //Animates the opening, closing and moving of Editor windows
    handleSubmit: true
});

myEditor.render();
// I just took a guess on which event to use here
myEditor.on('windowRender', function() {
    myEditor.setEditorHTML("Hello World");

});

以下是一个列表。

编辑器渲染时,您无法访问
setEditorHTML
。试试这个:

var myEditor = new YAHOO.widget.Editor('msgpost', {
    height: '300px',
    width: '522px',
    dompath: false, //Turns on the bar at the bottom
    animate: false, //Animates the opening, closing and moving of Editor windows
    handleSubmit: true
});

myEditor.render();
// I just took a guess on which event to use here
myEditor.on('windowRender', function() {
    myEditor.setEditorHTML("Hello World");

});
这是一份清单