CodeMirror onBlur and console.log () event

From what I read about CodeMirror, I had to write onBlur to my console log when I blur the text box. Nothing gets an echo.

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

Did I miss something?

+8
javascript jquery codemirror
source share
1 answer

Bind it using .on() as described in the CodeMirror documentation .

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

All Articles