If I use JavaScript to change the content of the (hidden) textarea that FCKeditor has replaced, will the FCKeditor reflect the change? If not, how would I get it to update?
Well after some testing, it looks like FCKeditor does NOT 'watch' the hidden textarea for changes (using textarea.onchange or similar). Also note (from O'Reilly's JavaScript reference: "the onchange() event hander is not invoked when the value property of a Textarea object is set by JavaScript". So that might not work anyway.
But this is the solution that I found: function changeIt() { newHtml = '<h1>This is the new HTML!<\/h1>'; document.form1.FCKeditor1.value = newHtml; if (this.FCKeditorAPI) { this.FCKeditorAPI.__Instances['FCKeditor1'].SetHTML(newHtml); } }
I'm using this as a way of providing 'templates' for my users. They can click a link and the content of the editor gets swapped out. There actually should be an 'if' statement in there to check for FCKeditor.
RE: Will updating the textarea update the edi
https://sourceforge.net/forum/message.p ... id=2731647
RE: Will updating the textarea update the editor?
But this is the solution that I found:
function changeIt() {
newHtml = '<h1>This is the new HTML!<\/h1>';
document.form1.FCKeditor1.value = newHtml;
if (this.FCKeditorAPI) {
this.FCKeditorAPI.__Instances['FCKeditor1'].SetHTML(newHtml);
}
}
I'm using this as a way of providing 'templates' for my users. They can click a link and the content of the editor gets swapped out. There actually should be an 'if' statement in there to check for FCKeditor.
Hope this helps others with similar issues.
-Jeff
RE: Will updating the textarea update the editor?
Whoop. Ignore that. I put it into the code example.
The cool thing about this template script is that it should work even if FCKeditor is not installed/invoked/compatible.