Search code examples
javascriptcodemirror

CodeMirror's onLoad function not working?


Just curious if anyone has setup CodeMirror before and got the onLoad function to work. With the latest version, it's not functioning. Here's my code:

cydonia.editor = CodeMirror.fromTextArea('query', {
    height: $('#query-text-space').css('height'),
    parserfile: ["tokenizexquery.js", "parsexquery.js" ],
    stylesheet: ["/common/codemirror/css/xmlcolors.css", "/common/codemirror/css/xqcolors.css"],
    path: "/common/codemirror/js/",
    continuousScanning: false, //500,
    lineNumbers: true,
    onLoad: function (n) {
        alert('loaded');

    }
}); 

Thanks!!!


Solution

  • Just specify function name, see the code below

    cydonia.editor = CodeMirror.fromTextArea('query', {
        height: $('#query-text-space').css('height'),
        parserfile: ["tokenizexquery.js", "parsexquery.js" ],
        stylesheet: ["/common/codemirror/css/xmlcolors.css", "/common/codemirror/css/xqcolors.css"],
        path: "/common/codemirror/js/",
        continuousScanning: false, //500,
        lineNumbers: true,
        onLoad: codeMirrorLoaded()
    }); 
    
    function codeMirrorLoaded(){
        alert("loaded");
    }