How do I enable Live Syntax Checking in the Ace Ed

2019-05-07 04:24发布

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条回答
我命由我不由天
2楼-- · 2019-05-07 05:02

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.

查看更多
登录 后发表回答