1
我正在使用nicEdit的基於Ember.js的平臺上工作。這裏是我的代碼如何從nicEditor + emberjs中刪除事件
RichHTMLView = Ember.TextArea.extend({
id: null,
editor: null,
didInsertElement: function(){
var view = this;
view.id = this.get("elementId");
view.editor = new nicEditor({
buttonList : ['bold','italic','underline','right','center','justify', 'link', 'ul', 'ol']
}).panelInstance(view.id);
//When the editor looses focus the content of the editor is passed to descr
view.editor.addEvent('blur',function(){
view.get('controller').set('descr',view.getViewContent());
});
//So the editor looks nice
$('.nicEdit-panelContain').parent().width('100%');
$('.nicEdit-panelContain').parent().next().width('100%');
},
getViewContent: function(){
var view = this,
inlineEditor = view.editor.instanceById(view.id);
return inlineEditor.getContent();
},
willClearRender: function(){
var view = this;
}
});
所以這個只要我哪些主機視圖頁面上工作得很好,但如果我過渡到另一條路線,認爲有一些剩菜,即編輯器被破壞,但我假設nicEdit跟蹤事件綁定,所以我最終將blur
事件綁定到編輯器,即在新的上下文中undefined
,因爲視圖不存在。
我最好的猜測是我需要以某種方式解除willClearRender
中的編輯器,但我不知道如何。