Michael Joseph Aubry
Michael Joseph Aubry

Reputation: 13422

Tinymce formats textarea with HTML.. Not showing in DOM?

Edit: Actually, I just remembered and its mentioned below, the second textarea doesnt update until a specific click function occurs.. I need to adjust the question...

TinyMce formats text... with <p> tags, wordpress text "html" textarea gets whatever is inputted into the tinymce, and somehow is formatted with the <p> tags.

I want to get the value of the textarea but this would get the value without the appropriate HTML, how is it possible to get the value with the

tags?

Read more below to understand what I mean.


More Detail The fiddle alone should show you exactly what I need it's quite simple I would think, but I am adding more detail just to give you an idea what I am truly trying to accomplish so that maybe you see a better way, but honestly I tried to think of everything this seems to be the most simple.

I am targeting the wordpress tinyMCE change event I use tinyMCE.activeEditor.getContent() I append the data to my plugin I do this perfectly fine. When user changes to the WordPress text "html" editor I could easily get the keyup value from it, but it looses formatting (FYI tinymce adds <p> tags). This formatting goes into the_content() it outputs into the live frontend with those tags, so this is all about keeping that formatting.

Whats weird to me is the text "html" area maintains that format in their textarea, but in the DOM "firbug inspector" there is just plain text and even when I get the value of that textarea it shows in my plugin as plain text, this causes a problem for me.

So that said my solution is the above, because the text "html" updates the tinyMCE on only when you click the tab though, I can update my plugin if you update the text "html" click the tinyMCE then click the plugin, this is not smooth though.

Upvotes: 0

Views: 530

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388316

Since a script is changing the value manually, you need to trigger the change event

jQuery('textarea.changing-textarea-focused').keyup(function() {   
    jQuery('textarea.not-focused').val(jQuery(this).val()).change()
});

Demo: Fiddle

Upvotes: 2

Related Questions