When I click send on my ajax form, all fields are submitted via POST except for CodeMirror. Only after a second click, all future forms are being submitted correctly.
What am I doing wrong?
Thanks!
$(document).ready(function() {
var options = {
target: '#code',
beforeSubmit: function() {
$('input#submit').attr('value','loading...');
},
success: function() {
$('input#submit').attr('value','Submit');
}
};
$('#form').submit(function() {
$(this).ajaxSubmit(options);
return false;
});
var editor = CodeMirror.fromTextArea(document.getElementById('codeenter'), {
height: "150px",
parserfile: "parsecss.js",
stylesheet: "csscolors.css",
path: "js/"
});
});
var editor = CodeMirror.fromTextArea(document.getElementById('codeenter'), {
height: "150px",
parserfile: "parsecss.js",
stylesheet: "csscolors.css",
path: "js/"
});
Try to add an onBlur Event:
var editor = CodeMirror.fromTextArea(document.getElementById('codeenter'), {
height: "150px",
parserfile: "parsecss.js",
stylesheet: "csscolors.css",
path: "js/"
onBlur: function () {
editor.save();
}
});
It will save the content of the editor back to the textarea if the editor loses focus. Solved the problem in my case.