I am using Yahoo's YUI2 rich text editor that replaces a standard text area. Without the 开发者_如何学GoRTE added the text area fields return the field contents correctly into my PHP code. However when I use the RTE code the jQuery "sucks up" the var and doesn't give it back to the text area on submit. Because of this the var (sectiontext1) is returning empty. Here is the js for the text area:
var myEditor1 = new YAHOO.widget.Editor('sectiontext1', {
height: '100px',
width: '870px',
dompath: false,
animate: true,
toolbar: {
titlebar: 'Section Text 1',
buttons: [
{ group: 'textstyle', label: '',
buttons: [
{ type: 'push', label: 'Bold', value: 'bold' },
{ type: 'push', label: 'Italic', value: 'italic' },
{ type: 'push', label: 'Underline', value: 'underline' },
{ type: 'separator' },
{ type: 'color', label: 'Font Color', value: 'forecolor', disabled: true },
{ type: 'separator' },
{ type: 'push', label: 'Create an Unordered List', value: 'insertunorderedlist' },
{ type: 'push', label: 'Create an Ordered List', value: 'insertorderedlist' },
{ type: 'separator' },
{ type: 'push', label: 'Indent', value: 'indent', disabled: true },
{ type: 'push', label: 'Outdent', value: 'outdent', disabled: true },
{ type: 'separator' },
{ type: 'push', label: 'HTML Link CTRL + SHIFT + L', value: 'createlink', disabled: true },
{ type: 'separator' },
{ type: 'push', label: 'Remove Formatting', value: 'removeformat', disabled: true }
]
}
]
}
});
myEditor1.render();
I thought I could just add this after the above and it would work but it doesn't:
$('#submit').click(function() {
myEditor1.saveHTML();
});
How do I get the code to return the var so I can use it in PHP?
Thanks!
What do you mean doesn't work? You may want to actually store the result in a variable and see if you got the html If you do have the html in that var you can then use it any way you want, including sending it to php via ajax request.
var html = myEditor1.saveHTML();
alert('editor html: ' + html);
精彩评论