admin管理员组

文章数量:1277887

So I have literally copied the "get started" code from ACE and then tried to add a marker. I copied the syntax from ACE's website which is the same as remended here: How can I highlight multiple lines with Ace?

All I get is an error in the console saying Undefined is not a function.

My goal is to add a marker so I can highlight a line of text. Any ideas why this is not working?

var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/javascript");
editor.getSession().addMarker(new Range(1,0,1,200),"ace_active_line","background");

So I have literally copied the "get started" code from ACE and then tried to add a marker. I copied the syntax from ACE's website which is the same as remended here: How can I highlight multiple lines with Ace?

All I get is an error in the console saying Undefined is not a function.

My goal is to add a marker so I can highlight a line of text. Any ideas why this is not working?

var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/javascript");
editor.getSession().addMarker(new Range(1,0,1,200),"ace_active_line","background");
Share Improve this question edited May 23, 2017 at 12:23 CommunityBot 11 silver badge asked May 18, 2014 at 20:02 RyanYRyanY 6651 gold badge8 silver badges21 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 14

Looks like you forgot to import Range

var Range = ace.require("ace/range").Range
var editor = ace.edit("editor");
editor.session.addMarker(new Range(1,0,1,200),"ace_active-line","fullLine");

also class name for active line marker have changed.

Generally when asking questions like this it is a good idea to create a jsbin like http://jsbin./ojijeb/570/edit, since it helps answering a lot

本文标签: javascriptAce Editor addMarker throwing erroStack Overflow