最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do I enable Live Syntax Checking in the Ace Editor - Stack Overflow

programmeradmin2浏览0评论

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");

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");
Share Improve this question edited Feb 24, 2014 at 22:51 Ari asked Feb 24, 2014 at 17:52 AriAri 2,00421 silver badges31 bronze badges 4
  • What error do you see? It works fine at jsbin./ojijeb/432/edit. – a user Commented Feb 25, 2014 at 13:39
  • @auser, the highlighting works, but I want it to mark syntax errors, like when you type an error here: ace.c9.io/#nav=about – Ari Commented Feb 25, 2014 at 15:17
  • Do the syntax error markers work for no language at all? Have you tried for JavaScript mode? Not all language modes have perfect syntax error marking support. – yerforkferchips Commented Feb 27, 2014 at 9:35
  • @yerforkferchips, that's correct, you can see it here: learneroo./modules/20/nodes/151 – Ari Commented Feb 27, 2014 at 14:57
Add a ment  | 

1 Answer 1

Reset to default 6 +50

Syntax checking is done via webworker which loads http://www.learneroo./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./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.

发布评论

评论列表(0)

  1. 暂无评论