Skip Navigation

[Resolved] wysiwyg (tinymce) field getcontent on change

This thread is resolved. Here is a description of the problem and solution.

Problem:

1.)Could you tell me where can I find the id of toolset wysiwyg editor field?

2.) Could you help me assist to trigger a function when the wysiwyg editor fields text changed?

Solution:

For example:

https://toolset.com/forums/topic/wysiwyg-tinymce-field-getcontent-on-change/#post-1876629

Relevant Documentation:

This support ticket is created 4 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 2 voices.

Last updated by SteffenM1628 4 years ago.

Assisted by: Luo Yang.

Author
Posts
#1875439

Tell us what you are trying to do?
Hey there, i have a toolset wysiwyg field. Toolset uses the tinymce Rich Text Editor.
Now i am trying to get the html Content from the Editor, when the Editor is changed.
I have read the documentation of the tinymce and there are a lot of methods available.

I have tried this:

tinymce.activeEditor.isDirty(function(){            // tinymce.activeEditor (Gets the current active Editor) & isDirty() detects changes
  	var getContent = tinymce.activeEditor.getContent();         // gets the Content of the active editor
    console.log(getContent)
  });

Is there any documentation that you are following?
hidden link

Thanks for your help!

#1875491

Hello,

The activeEditor method works when there is only one tinymce editor, when there are multiple tinymce editors, you will need to specific the tinymce editor, for example:
https://stackoverflow.com/questions/16016250/how-to-get-tinymce-content-from-more-than-one-text-area

#1875571

Hey Luo,

thanks for your reply. I do have only one editor on my site. But thanks for the hint.
1.)Could you tell me where can i find the id of toolset editor field?
2.) Could you help me assist to trigger a function when the editor fields text changed?

Like i said i tried the code above to get the content of the editor, every time when the editor text is changed.

Thank you so much!

#1876629

For example:

document.addEventListener('DOMContentLoaded', function(event) {
	window.tinyMCE.on( 'AddEditor' , function( event ) {
		var editor = event.editor;

		if( editor.id.startsWith( 'wpcf-' ) ) {
			console.log(editor.id); // tinyMCE ID
			editor.on( 'change', function() {
					var getContent = editor.getContent();         // gets the Content of the active editor
					console.log(getContent)
			} );
		};
	} );
});

For your reference

#1876699
Bildschirmfoto 2020-12-15 um 10.37.33.png

Hey Luo thanks for your reply. Works like charm.

Thanks a lot. But i found another problem with the wysiwyg field in toolset.
In the documentation of tinymce you find some plugins for the editor.
I would like to use the autolink plugin mentioned here: hidden link
I tried to use it correctly. I found this for wordpress:
https://codex.wordpress.org/TinyMCE

When i trying to use the autolink plugin i get an error in the frontend. Failed to load plugin (screenshot)
Thanks for your help.

New threads created by Luo Yang and linked to this one are listed below:

https://toolset.com/forums/topic/but-i-found-another-problem-with-the-wysiwyg-field-in-toolset/

#1877685

I assume the original question is resolved, according to our support policy, we prefer one ticket one question, for other new questions, please check the new thread here:
https://toolset.com/forums/topic/but-i-found-another-problem-with-the-wysiwyg-field-in-toolset/

#1878585

My issue is resolved now. Thank you!