1

を使用しようとしていますがYUI2 Rich Text Editor、正しく機能しないようです。テキストエリアのコンテンツを保存して表示できません。助けてくれてありがとう。

Javascript:

<script type="text/javascript">
var myEditor = new YAHOO.widget.Editor('msgpost', {
height: '80px',
width: '600px',
dompath: false, //Turns on the bar at the bottom
animate: true,
handleSubmit: false,
toolbar: {
titlebar: 'Comments:',
    buttons: [
        { group: 'textstyle', label: 'Font Style',
            buttons: [
                { type: 'push', label: 'Bold', value: 'bold' },
                { type: 'separator' },
                { type: 'push', label: 'Italic', value: 'italic' },
                { type: 'separator' },
                { type: 'push', label: 'Underline', value: 'underline' },
                { type: 'separator' },
                { type: 'push', label: 'Subscript', value: 'subscript', disabled: true },
                { type: 'separator' },
                { type: 'push', label: 'Superscript', value: 'superscript', disabled: true },

            ]
        },
        { type: 'separator' },
        { group: 'indentlist', label: 'Lists',
        buttons: [
        { type: 'push', label: 'Unordered List', value: 'insertunorderedlist' },
        { type: 'push', label: 'Ordered List', value: 'insertorderedlist' }
        ]
        }

    ]
}
});
myEditor.render();

//Inside an event handler after the Editor is rendered
YAHOO.util.Event.on('yuiButton', 'click', function() {
//Put the HTML back into the text area
myEditor.saveHTML();

//The var html will now have the contents of the textarea
var htmltest = myEditor.get('element').value;

document.getElementbyId("printHere").innerHTML = htmltest;
});
</script>

に続いて、テキストエディタ内の内容を表示するためにyui tutorialのみを追加しましたinnerHTMLdivid="printHere"

HTML:

<body>
<form method="post" class="yui-skin-sam">
    <div class="yui-skin-sam">
        <textarea name="msgpost" id="msgpost" style="width: 600px; height: 80px;">
            A Commisioner has been commisioned
        </textarea>

    </div>
</form>
<input type="button" name="yuiButton" value="Save" />
<div id="printHere"></div>


</body>
4

0 に答える 0