I have this problem with codemirror which is quite tricky and I have no idea how to get around to it.
The data from codemirror just won't be serialized without the submit event - that's what I found out so far - like this below,
$(':submit').submit_form();
(function($){
$.fn.extend({
submit_form: function(options) {
var defaults = {
}
var options = $.extend(defaults, options);
var o = options;
var $cm = this.click(function(e){
var form = $(this).closest('form');
alert(form.serialize()); // the textarea field with codemirror returns empty
$.post(form.attr('action'),form.serialize(),function(xml)
{
...
...
}
});
}
});
})(jQuery);
html,
<textarea name="code_1" id="code_1" title="EMBED CODE" class="editor-codemirror" cols="" rows=""></textarea>
I have to change this line
var $cm = this.click(function(e){
to
var $cm = this.submit(function(e){
then the data in the codemirror can be serialised.
but I have to attach the plugin to the click button first and find its closest form and serialise its form data before ajax post
. So I must use click event to trace the closest form.
I wonder if anyone has come across this problem before and what is the solution.