我在一页上有几个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()]
});
}小提琴手:http://jsfiddle.net/3nHas/25/
提前谢谢。
发布于 2014-06-19 15:12:22
你想要元素吗?还是编辑器的一个例子?无论如何,您应该在被调用函数的第二个参数中找到所需的内容。
editor[i].on('input', function(e, target) {
console.log(target);
});https://stackoverflow.com/questions/24309792
复制相似问题