Javascript 将单击事件附加到编辑器中的元素
这是ckeditor4 angular中一个元素的来源,我想附加click事件以实现自定义功能Javascript 将单击事件附加到编辑器中的元素,javascript,angular,ckeditor,ckeditor4.x,Javascript,Angular,Ckeditor,Ckeditor4.x,这是ckeditor4 angular中一个元素的来源,我想附加click事件以实现自定义功能 <div class="fractional-block" id="fractional-block"><span>5</span><svg height="5" width="100%"><line stroke="#000" stroke-wid
<div class="fractional-block" id="fractional-block"><span>5</span><svg height="5" width="100%"><line stroke="#000" stroke-width="2" x1="0" x2="100%" y1="0" y2="0"></line></svg><span>6</span></div>
但它给出了错误“无法读取未定义的属性”是否有人可以指导我如何使用元素附加click事件?关于CKEditor中的*属性 CKEditor在加载内容时对*属性进行编码,这样它们就不会破坏编辑功能。例如,onmouseout在编辑器内成为数据cke pa onmouseout,然后,当从编辑器获取数据时,该属性被解码 这没有配置选项,因为它没有意义 注意:在为编辑器的可编辑元素内的元素设置属性时,应将其设置为受保护的格式: setAttribute('data cke pa onclick','alert('blablabla'); CKEditor中的可单击元素 如果要在编辑器中观察单击事件,则以下是正确的解决方案:
editor.on('contentDom',function()){
var元素=editor.document.getById('bar');
editor.editable().attachListener(元素“单击”,函数(evt){
// ...
//获取事件目标(事件委派所需)。
evt.data.getTarget();
} );
} );代码>我认为它应该是CKEDITOR.instances[instanceName]
并且您有一个输入错误,然后它给出“属性'instances'在类型'CKEditorComponent'上不存在”。您是指'instance'吗?“此错误”
this.CKEDITOR.instance['fractional-block'].on('contentDom', function() {
this.document.on('click', function(event){
console.log('click', event)
});
});