2016-07-27 132 views
0

我正在使用react-tinymce 0.2.3和tinymce 4.2.7。 按下面的代碼在handleEditorChangee.target.getContent()的電話後,我收到錯誤tinymce.4.2.7.min.js未捕獲TypeError:無法讀取null的屬性'body'

tinymce.4.2.7.min.js:10 Uncaught TypeError: Cannot read property 'body' of null

我試圖把e.target.getContent()在jQuery的ready功能,但沒有成功。

我使用的是反應0.13.3。

<TinyMCE config={...} content={html} onBlur={this.handleEditorChange} /> 
+0

你應該試試facebook上的draftjs。這是一個很好的替代tinymce。 – vijayst

回答

2

文檔的ready()功能並不能保證TinyMCE的初始化,並準備進行互動。有一個init()函數,您可以添加到您的TinyMCE配置,它會告訴您編輯器本身何時被初始化並準備好進行交互。你可以把代碼放在你的TinyMCE初始化中:

tinymce.init({ 
    selector: '.editor', 
    .... 
    setup: function (editor) { 
     editor.on('init', function() { 
     this.setContent('Using the on init stuff!'); 
    }); 
}); 
+0

讓我試試@ michale-fromin –

+0

Thanks @ michale-fromin issue in react-tinymce 0.2.3 on calling of https://github.com/instructure-react/react-tinymce/blob/51906f8e261453207cf2796c6c59f5ee1a434f29/lib/components/TinyMCE .js#L50'this._init'它有兩個參數,在這裏它只被調用一個,並使內容爲'undefiend'。 –

相關問題