我有一个使用 EmberJS 创建的单页应用程序。
我在页面上有 3 个文本区域。
一旦 textarea 被插入到 dom 中,我正在渲染 ckeditor,并且我在控制器上标记一个属性,记录 ckeditor 已被渲染,这样我就不会多次渲染它。
我什至正在调查 dom 以验证那里目前没有编辑器。
刷新页面时,我随机收到此错误:
Uncaught TypeError: Cannot call method 'unselectable' of null
我不知道是什么导致它或现在阻止它。当它不抛出该错误时,所有 3 个 ckeditor 看起来都很好。
这是我的编辑器启动代码:
Lrt.PrioritizationEditableTextArea = Ember.TextArea.extend({
areaVisible: false,
isRendered: false,
isInserted: false,
didInsertElement:function(){
this.set('isInserted', true);
},
renderEditor:function(){
var self = this;
var selfID = self.get('elementId');
if( !this.get('isRendered') && this.get('isInserted') && $('#'+selfID).parent().find('cke').length === 0 ){
var editor = $('#'+selfID).ckeditor({
toolbar:[
{ name: 'document', items:['Source'] },
{ name: 'clipboard', items:['Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']},
{ name: 'editing', items:['scayt']},
{ name: 'basicstyles', items:['Bold', 'Italic', 'Underline', 'TextColor', 'BGColor', '-', 'RemoveFormat']},
{ name: 'styles', items:['FontSize']},
{ name: 'paragraph', items:['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-']}
]
}).editor;
editor.on('change', function(e){
if(e.editor.checkDirty()){
self.set('value', editor.getData());
}
});
this.set('isRendered', true);
}
}.observes('areaVisible')
});
我还使用 ckeditor 的“onChange”插件在编辑器中发生任何更改并响应它时触发“onChange”事件。
我试过的:
- 删除 onChange 插件
- 将 ckeditor 更改为 4.3 beta 版本
- 删除工具栏自定义
- 移除 onChange 事件监听器
- 验证所有文本区域在渲染时是否有内容
我需要做什么来解决这个问题?
编辑
这是堆栈跟踪:(我正在我的应用程序中添加 ver 字符串)
a (ckeditor.js?ver=2.0.0:291)
(anonymous function) (ckeditor.js?ver=2.0.0:287)
i (ckeditor.js?ver=2.0.0:10)
CKEDITOR.event.CKEDITOR.event.fire (ckeditor.js?ver=2.0.0:12)
CKEDITOR.editor.CKEDITOR.editor.fire (ckeditor.js?ver=2.0.0:13)
CKEDITOR.event.CKEDITOR.event.fireOnce (ckeditor.js?ver=2.0.0:12)
CKEDITOR.editor.CKEDITOR.editor.fireOnce (ckeditor.js?ver=2.0.0:13)
(anonymous function) (ckeditor.js?ver=2.0.0:223)
m (ckeditor.js?ver=2.0.0:203)
CKEDITOR.scriptLoader.load (ckeditor.js?ver=2.0.0:203)
(anonymous function) (ckeditor.js?ver=2.0.0:222)
(anonymous function) (ckeditor.js?ver=2.0.0:210)
(anonymous function) (ckeditor.js?ver=2.0.0:208)
m (ckeditor.js?ver=2.0.0:203)
CKEDITOR.scriptLoader.load (ckeditor.js?ver=2.0.0:203)
CKEDITOR.resourceManager.load (ckeditor.js?ver=2.0.0:207)
h (ckeditor.js?ver=2.0.0:209)
(anonymous function) (ckeditor.js?ver=2.0.0:210)
m (ckeditor.js?ver=2.0.0:220)
(anonymous function) (ckeditor.js?ver=2.0.0:220)
(anonymous function) (ckeditor.js?ver=2.0.0:397)
(anonymous function) (ckeditor.js?ver=2.0.0:208)
m (ckeditor.js?ver=2.0.0:203)
q (ckeditor.js?ver=2.0.0:203)
r (ckeditor.js?ver=2.0.0:203)
(anonymous function) (ckeditor.js?ver=2.0.0:204)
编辑#2:
这是发生问题的应用程序特定区域的小提琴:http: //jsfiddle.net/sSaCd/3/