ace编辑器onchange无法正常工作 [英] ace editor onchange not working
本文介绍了ace编辑器onchange无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用ace编辑器在代码游乐场上工作,我正在尝试使用ace编辑器onChange但是当我输入时没有任何反应。
我的代码是
i'm working on a code playground using ace editor and i am trying to use ace editor onChange but nothing happens when I type.
my code is
<style>
html{padding:0px}
#editor {
border-radius:5px;
width:500px;
height:100%
}</style>
<a href="#" onclick="update()">go</a>
<div id="editor" onChange="update()">
function foo(items) {
var x = "All this is syntax highlighted";
return x;
}
</div>
<script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.getSession().setUseWorker(false);
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/html");
editor.getSession().on('change', function() {
update()
});
</script>
<script>;
new function update()
{
var ace = editor.getSession().getValue();
var divecho = document.getElementById("output");
divecho.innerHTML=ace
}</script>
<div id="output"></div>
任何帮助将不胜感激
推荐答案
new function update()
应该是
function update()
当它是全局变量时,使用ace作为局部变量是不明智的。
Also it is not wise to use ace as a local variable when it is a global.
这篇关于ace编辑器onchange无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文