I\'m in a curious situation where I previously had no problem achieving what I\'m looking for. The following code is a part of an HTML page which is to host a TinyMCE rich t
We're using TinyMCE here lately as well. I'm particularly puzzled about the change the the style attribute of the textarea to hide the element. Very odd.
I'm curious what your configuration file looks like (some documentation on configuration files at: django)
wow... you're using a LOT of tinyMCE plugins. I'll try to research further when I get some time and see if I can't figure out some likely suspects.
That second example <textarea ... /> is empty tag notation. If you want the text to be inside the tage you need to do it like the first way <teatarea ....>foo</textarea>
What is outputting the textarea tags? Can you debug that to see if it is doing the empty tag notation?
Eric
It appears that I have solved the problem, unless there are any edge cases which ruins the solution. I use the following PHP code on page content before I save it to the database:
$content = str_replace(chr(10), "", $content);
$content = str_replace(chr(13), "", $content);
$content = str_ireplace('<','​<',$content);
What it does is it removes any newlines and then prepend a zero-width invisible character before any beginning tag. This text is then later inserted between the textarea tags before TinyMCE does its magic. I don't know why but this does not trigger the problem and the appended characters are not shown in the final html or in the html view of TinyMCE, so the only problems I can see with this solution is the performance hit. A detail is that it appears only the start tags need to be prepended in this way, but I haven't taken this into consideration here, for simplicity.
Given that the presence of <p>
tags causes the transformation, I suspect that your HTML ends up looking like:
...
<textarea id="editing_field"><p>This text is supposed to appear in the rich textbox</p></textarea>
...
Unfortunately, HTML elements aren't technically allowed inside <textarea>
tags, so something may be considering the <p>
tags as the start of a new block element, implicitly closing your textarea. To fix this, you can encode the angle brackets:
...
<textarea id="editing_field"><p>This text is supposed to appear in the rich textbox</p></textarea>
...
Using PHP, this can be done by sending your value through htmlspecialchars()
before echoing it to the page.
tinyMCE.activeEditor.setContent('some') works for me.Cheers
To change an specific tinymce field, you can do this:
tinyMCE.get('editing_field').setContent('your default text');