admin管理员组

文章数量:1335854

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.

本文标签: javascriptImplementing CodeMirror Syntax HighlighterStack Overflow