Reputation: 3299
I'm using tinyMCE with my reactjs app. The onChange event will fire once, properly reflecting the input data in an alert. Then I get nothing.
Here's the relevant code:
<Editor init={{
statusbar: false,
menubar: false,
}}
onChange={this.SetText}
/>
onChange method:
SetText(e) {
alert(e.target.getContent());
}
Upvotes: 2
Views: 7329
Reputation: 343
Actually the event you using is not right. For reactJs plugIn they have onEditorChange. You can use it as following
<Editor
apiKey="MyAPIKey"
initialValue=""
init={{
height: 500,
menubar: false,
plugins: [
'advlist autolink lists link image charmap print preview anchor',
'searchreplace visualblocks code fullscreen',
'insertdatetime media table paste code help wordcount'
],
toolbar:
'undo redo | formatselect | bold italic backcolor | \
alignleft aligncenter alignright alignjustify | \
bullist numlist outdent indent | removeformat | help'
}}
onEditorChange={this.onChange}
/>
and then you can access editor's content by using
onChange = (content) => {
console.log(content);
}
e.target
is not required
Upvotes: 7
Reputation: 582
Maybe one of this events pass better then onChange?
https://www.tiny.cloud/docs/advanced/events/
Upvotes: 0