2013-02-26 6 views
8

Von dem, was ich über CodeMirror gelesen habe, sollte ich onBlur in mein Konsolenprotokoll geschrieben haben, wenn ich den Textbereich verwische. Nichts wird widerhallen.CodeMirror onBlur Ereignis und console.log()

var textarea = document.getElementById('block'); 
var editor = CodeMirror.fromTextArea(textarea, { 
    lineNumbers: false, 
    content: textarea.value, 
    onBlur: function() { 
     console.log("onBlur"); 
    } 
}); 

Habe ich überhaupt etwas verpasst?

Antwort

12

Binden Sie es mit .on() wie in the CodeMirror's Events documentation beschrieben.

var textarea = document.getElementById('block'); 
var editor = CodeMirror.fromTextArea(textarea, { 
    lineNumbers: false, 
    content: textarea.value, 
}); 
editor.on("blur", function(){ 
    console.log("onBlur"); 
}); 
+0

Dank, fand ich es hier https://github.com/marijnh/CodeMirror/issues/818 zu – ngplayground

+1

@DonaldSutherland, Groß. Ich habe die Dokumentation gelesen – Alexander