Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I resolve an AutoComplete error when using CodeMirror?

I want to use the AutoComplete of CodeMirror, but I'm getting the error:

Uncaught TypeError: Cannot read property 'javascript' of undefined

CodeMirror.commands.autocomplete = function(cm) {
    CodeMirror.showHint(cm, CodeMirror.hint.javascript); // Error Here
}

var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
    lineNumbers: true,
    extraKeys: {"Ctrl-Space": "autocomplete"}
});
like image 588
awesome_dude Avatar asked Mar 23 '26 02:03

awesome_dude


1 Answers

In order to use autocomplete capabilities, you must insure to include the appropriate scripts, i.e. show-hint.js, show-hint.css and javascript-hint.js (which seems like the one causing the fuss here).

Take a look at the autocomplete demo's source code for a reference.

like image 187
Eliran Malka Avatar answered Mar 25 '26 16:03

Eliran Malka