Я пытаюсь использовать YUI2 Визуальный редактор
, но кажусь, что не могу заставить его работать правильно, я не могу спасти и показать содержание текстовой области.
Заранее спасибо за помощь.
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>
just followed the yui tutorial
, and only added the innerHTML
to display what inside the text editor in the div
with id="printHere"
HTML:
<body>
<form method="post" class="yui-skin-sam">
<div class="yui-skin-sam">
</div>
</form>
<input type="button" name="yuiButton" value="Save" />
<div id="printHere"></div>
</body>