Here’s an issue I came across today: I’m updating an article in my CMS, using jquery.ajax, and everything works well, until I notice that the TinyMCE-textarea’s contents isn’t updated.
My workaround/hack, in case someone runs into the same problem:
Example JS-function:
function send_form() {
$.ajax({
type: 'POST',
url: 'foo.php',
data: $('form').serialize() + '&article=' + tinyMCE.getContent('article'),
success: function(){
// Show success-message, reload article-list etc.
},
error: function() {
// // Show error-message
}
});
}
The JS is a stripped down un-tested version of my function, but it shows the workaround: adding a POST-variable at the end of the request, after serializing the form content, getting the textarea’s current content with tinyMCE.getContent:
data: $('form').serialize() + '&article=' + tinyMCE.getContent('article'),
This means that “article” is sent twice, but in my tests the last one is used. I’ll look into how to overwrite the initial “article”, but at least this seems to work.








0 Responses to “jquery/AJAX/TinyMCE”