我如何添加事件监听器到dojo编辑器的内容? [英] How can i add event listener to the content of dojo editor?

查看:176
本文介绍了我如何添加事件监听器到dojo编辑器的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用dojo编辑器。我有一个问题,所以你可以帮我解决这个
问题。



我的问题是:如何添加事件侦听器来标记我输入编辑器如onClick,onMouseover等...



例如:我向编辑器内容输入图像标签:

  var ed = dijit.byId(myEditor); //我的编辑器有id id myEditor 
var img =< img src ='myPic.jpg'alt =''id ='myPic'/>; //我的图像标签
ed.forcus();
ed.execCommand(insertionthtml,img); //将图像标签插入编辑器内容

将图像标签插入编辑器后,现在我要添加点击事件,因为我想要点击该图像和一个小的工具提示显示选择对齐该图像左或右。



感谢任何建议!

解决方案

查看我的jsFiddle示例: http://jsfiddle.net/phusick/j475Q/



基本上,您要连接的节点是 editor.editNode

  var editor = dijit.byId(editor); 
dojo.connect(editor.editNode,ondblclick,this,_onDblClick);

之后,在 _onDblClick 找出哪个类型的节点被删除并决定是否继续执行一个动作:

  _onDblClick:function(e){
var target = e.target;
var tag = target.tagName? target.tagName.toLowerCase():;
if(tag ==img){
dojo.withGlobal(editor.window,selectElement,selectionapi,[target]);
}
}

我在 LinkDialog plugin(dijit / _editor / plugins / LinkDialog.js)。看看更多的灵感。


I am working with dojo editor. And I have a problem so could you help me to solve this problem.

My problem is: how can I add event listener to tag that I input to the editor such as onClick, onMouseover, etc...

For Example : I input an image tag to the editor content:

var ed=dijit.byId("myEditor"); //my editor has id id myEditor
var img = "<img src='myPic.jpg' alt='' id='myPic'/>"; //my image tag
ed.forcus();
ed.execCommand("inserthtml", img); //insert image tag into editor content

After inserting image tag to the editor, now I want to add "click" event to it, because i want click that image and a small tooltip showed to choose align that image left or right.

Thanks for any suggestion!

解决方案

Check out my jsFiddle example: http://jsfiddle.net/phusick/j475Q/

Basically the node you want to connect is editor.editNode:

var editor = dijit.byId("editor");
dojo.connect(editor.editNode, "ondblclick", this, "_onDblClick"); 

Afterwards, in _onDblClick method you have to find out which kind of node was dblclicked and decide whether to proceed with an action:

_onDblClick: function(e) {
    var target = e.target;
    var tag = target.tagName ? target.tagName.toLowerCase() : "";
    if(tag == "img") {        
        dojo.withGlobal(editor.window, "selectElement", selectionapi, [target]);
    }
}

I found this in the LinkDialog plugin (dijit/_editor/plugins/LinkDialog.js). Look there for more inspiration.

这篇关于我如何添加事件监听器到dojo编辑器的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆