Reputation: 211
I was trying to use ckeditor with official jQuery Form Plugin for AJAX based forms but with the first submit I dont get the data. If I submit it for the second time only then it works. Any suggestions on this?
Upvotes: 0
Views: 807
Reputation: 199
With a jQuery Form Plugin do:
$(".ajaxForm").ajaxForm({
beforeSerialize: function(){
UpdateCKEditors();
}
});
function UpdateCKEditors() {
for (var i in CKEDITOR.instances) {
CKEDITOR.instances[i].updateElement();
}
}
Upvotes: 0
Reputation: 514
I had a similar issue, and while there were a few different approaches (i.e. event binding), this was the simplest solution I came up with.
$(document).ready(function () {
$('[type="submit"]').click(function () {
UpdateCKEditors();
});
});
/// <summary>
/// Updates the textarea elements of all CKEditor instances.
/// This method is intended to be used onsubmit
/// </summary>
function UpdateCKEditors() {
for (var i in CKEDITOR.instances) {
CKEDITOR.instances[i].updateElement();
}
}
Upvotes: 4