webfashionist / RichText

WYSIWYG editor developed as jQuery plugin
GNU Affero General Public License v3.0
112 stars 62 forks source link

Clear rich text textarea #95

Closed aahondema closed 1 year ago

aahondema commented 1 year ago

Hi,

I am trying to clear the content of a rich text textarea by using some javascript:

function clearEditor() { document.getElementById('editor').value = ''; }

However, this does not work. Is there a way to clear the textarea using Javascript?

Thanks in advance, Adrian The Netherlands

webfashionist commented 1 year ago

Hi @aahondema

as there is the editor and the textarea field, you'll need both containers to be set to an empty value. I'd however recommend to set the correct value directly into the <textarea> element instead of fiddling around with additional JavaScript to get to that result.

aahondema commented 1 year ago

Hi,

Yes, I understand. But based on the option in a select box (which links to various documents) I need to load other documents in the editor. Before I load a new document, I will need to clear the previous one first.

Adrian

webfashionist commented 1 year ago

Hi @aahondema

With the latest commit you are able to get, set and clear the content of the editor. Have a look at the Readme in order to see how you can implement it in your code.

Hopefully this helps