javascript - Implementing CodeMirror Syntax Highlighter - Stack Overflow

I am trying to make use of this Syntax highlighter. I have tried to implement their example and I alway

I am trying to make use of this Syntax highlighter. I have tried to implement their example and I always seem to get this error in firebug:

place is not a function else place(div);

Here is my code, I thought it was a path issue, but everything looks right:

<textarea id="code1" rows="20" cols="20">
select * from where this = done
</textarea>

<script type="text/javascript" src="codemirror/js/codemirror.js"></script>

<script type="text/javascript">

var editor = new CodeMirror('code1', {
  height: "150px",
  parserfile: "codemirror/contrib/sql/js/parsesql.js",
  stylesheet: "css/sqlcolors.css",
  textWrapping: true
});

</script>

If you look at the source code of that example page, its similar to mine yet, the text in the text area doesn't get highlighted and I always get that error.

Thanks all for any help

I am trying to make use of this Syntax highlighter. I have tried to implement their example and I always seem to get this error in firebug:

place is not a function else place(div);

Here is my code, I thought it was a path issue, but everything looks right:

<textarea id="code1" rows="20" cols="20">
select * from where this = done
</textarea>

<script type="text/javascript" src="codemirror/js/codemirror.js"></script>

<script type="text/javascript">

var editor = new CodeMirror('code1', {
  height: "150px",
  parserfile: "codemirror/contrib/sql/js/parsesql.js",
  stylesheet: "css/sqlcolors.css",
  textWrapping: true
});

</script>

If you look at the source code of that example page, its similar to mine yet, the text in the text area doesn't get highlighted and I always get that error.

Thanks all for any help

Share Improve this question edited Oct 14, 2012 at 21:50 jack 1,2631 gold badge11 silver badges7 bronze badges asked Apr 26, 2010 at 13:57 AbsAbs 58k103 gold badges282 silver badges417 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

Change the code that initializes CodeMirror to the following and I think it will work:

var editor = CodeMirror.fromTextArea('code1', {
  height: "150px",
  parserfile: "codemirror/contrib/sql/js/parsesql.js",
  path: "codemirror/js/",
  stylesheet: "css/sqlcolors.css",
  textWrapping: true
});

The important parts are using CodeMirror.fromTextArea rather than new CodeMirror and providing a value for path in the object passed into CodeMirror.fromTextArea.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742398282a4436391.html

相关推荐

  • javascript - Implementing CodeMirror Syntax Highlighter - Stack Overflow

    I am trying to make use of this Syntax highlighter. I have tried to implement their example and I alway

    3小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信