Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/451.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Ace.js.on事件_Javascript_Ace Editor - Fatal编程技术网

Javascript Ace.js.on事件

Javascript Ace.js.on事件,javascript,ace-editor,Javascript,Ace Editor,我在一个页面上有几个ace.js编辑器。它们存储在一个数组中 如何确定输入文本的编辑器 var editor = {first: ace.edit("editor"), second: ace.edit("editor1"), third: ace.edit("editor2")}; for(var i in editor) { editor[i].getSession().setMode("ace/mode/javascript"); editor[i].on('input'

我在一个页面上有几个ace.js编辑器。它们存储在一个数组中

如何确定输入文本的编辑器

var editor = {first: ace.edit("editor"), second: ace.edit("editor1"), third: ace.edit("editor2")};

for(var i in editor) {
    editor[i].getSession().setMode("ace/mode/javascript");
    editor[i].on('input', function() {
        console.log(this); // How to get current editor? this returns [function()]
    });
}
jsfiddle:


提前谢谢。

您想要元素吗?还是编辑器的一个实例?无论如何,您应该在被调用函数的第二个参数中找到所需的内容

editor[i].on('input', function(e, target) {
    console.log(target);
});