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?
And I'm talking questions asked in this forum for the FAQ, not the client one... realy someone clearer should do it, but what the hey, this non-college dude will give it the old college try... however that goes... =]
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
Here is the link one of the methods of getting stuff into the iframe.
https://sourceforge.net/forum/message.p ... id=2731647
And I'm talking questions asked in this forum for the FAQ, not the client one... realy someone clearer should do it, but what the hey, this non-college dude will give it the old college try... however that goes... =]
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.