Trix: How can I programatically delete all text

Created on 8 Mar 2019  路  1Comment  路  Source: basecamp/trix

hi 馃憢 ,

I am using trix in a form where I want to "clear" the editor contents after the form submits. I am not seeing a clear way from the API how to do this. The best I have come up with is something like:

editor.setSelectedRange([0, editor.getDocument().getLength()]);
editor.deleteInDirection('forward');

but this doesn't actually delete the text in the document, though it resets the cursor position.

Most helpful comment

Figured it out:

editor.loadHTML('')

does the trick 馃憤

>All comments

Figured it out:

editor.loadHTML('')

does the trick 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

acapro picture acapro  路  3Comments

atuttle picture atuttle  路  4Comments

adamdebono picture adamdebono  路  3Comments

divyenduz picture divyenduz  路  3Comments

adueck picture adueck  路  3Comments