javascript - CodeMirror using jQuery .keyup on editor textarea -
i want getvalue of codemirror editor on keyup did not work. here's the fiddle
var mixedmode = { name: "htmlmixed", scripttypes: [{matches: /\/x-handlebars-template|\/x-mustache/i, mode: null}, {matches: /(text|application)\/(x-)?vb(a|script)/i, mode: "vbscript"}] }; var editor = codemirror.fromtextarea(document.getelementbyid("html"), {mode: mixedmode,linenumbers: true }); $(document).ready(function(){ $("#html").keyup(function(){ html = editor.getvalue(); alert(html); }); });
codemirror hides textarea
element, listening events of editor instance can use on
method:
$(document).ready(function () { editor.on('change', function () { html = editor.getvalue(); alert(html); }); });
you can find list of supported events in codemirror's manual.
Comments
Post a Comment