CodeMirror.connect is not a function


#1

Hello,

I am trying to use the search functionality (https://codemirror.net/2/demo/search.html) and I am receiving the following error in the console when I try to type anything:

dialog.js:27 Uncaught TypeError: CodeMirror.connect is not a function
    at Li.openDialog (dialog.js:27)
    at dialog (search.js:71)
    at doSearch (search.js:157)
    at CodeMirror.commands.find (search.js:243)
    at Li.execCommand (codemirror.min.js:1)
    at HTMLInputElement.document.querySelector.onkeypress (current_configs:446)

To mention here I have included all the appropriate files (with jQuery):
codemirror.css
dialog.css

codemirror.min.js
dialog.js
searchcursor.min.js
search.js

Also my CodeMirror Config is the following:

// we format the json
 $('.panel-body').val(JSON.stringify(config, null, 4));

 var codeMirrorConfig = CodeMirror.fromTextArea(document.getElementById("panel-body"), {
    lineNumbers: true,
   extraKeys: {"Ctrl-Space": "autocomplete"},
   mode: "text/javascript",
    readOnly: 'true'
});

Thank you.


#2

Try upgrading to the current code. CodeMirror.connect existed at one point, but hasn’t for a long time, so it might be that you’re mixing old addon code with the current core library.


#3

Hello,

You are correct, after putting the latest version I do not longer get the error.

Thank you.