Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeMirror onBlur event and console.log()

From what I've read about CodeMirror I should have onBlur written to my Console Log when I Blur the textarea. Nothing gets echo'd.

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

Have I missed anything out at all?

like image 461
ngplayground Avatar asked Feb 26 '13 16:02

ngplayground


1 Answers

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

var textarea = document.getElementById('block');
var editor = CodeMirror.fromTextArea(textarea, {
    lineNumbers: false,
    content: textarea.value,
});
editor.on("blur", function(){
    console.log("onBlur");
});
like image 131
Alexander Avatar answered Oct 17 '22 03:10

Alexander