How do I enable Live Syntax Checking in the Ace Editor

穿精又带淫゛_ 提交于 2019-12-07 11:30:12

问题


Ace Editor has Live Syntax Checking, which can check code as it's being typed for syntax errors.

I have a Rails 3.2 site with the Ace file included on each coding page. I added a require statement to the javascript to tell Ace where the worker file is, but it's still not working. How do I get Live Syntax checking to work?

Each coding page includes:

<%= javascript_include_tag "ace-src/ace.js" %>
<%= javascript_include_tag "ace-editor" %>

The Ace files are located in the ace-src folder. I aded this code to ace-editor.js:

require("ace/config").set("workerPath", "/assets/ace-src");

回答1:


Syntax checking is done via webworker which loads http://www.learneroo.com/assets/ace-src/worker-javascript.js file, but in your site that file seems to be empty. I only see ; in it.
In the jsfiddle i showed earlier http://jsbin.com/ojijeb/432/edit, it didn't work because of cross origin restrictions on web workers (which i didn't notice since was running chrome with --disable-web-security), but thanks to latest Ace update, it works now.



来源:https://stackoverflow.com/questions/21995198/how-do-i-enable-live-syntax-checking-in-the-ace-editor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!