UPDATE
well tell you waht! this bug is fixed without me changing anything!.. verry strange.. but it's fixed :)
I'm trying to add some content to the default wordpress editor using jquery:
if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) {
tinyMCE.EditorManager.activeEditor.execCommand('mceSetContent', false, "some text...");
console.log(tinyMCE);
}
Then I got this error
Uncaught TypeError: Cannot call method 'execCommand' of null
Strange because this used to work before!! (I disabled all the plugins and still the problem occurs) It is strange because the code works on my local install and not on the online website :(
I have noticed that in the local install, tinymce is called using a php file
wp-includes/js/tinymce/wp-tinymce.php?c=1&ver=345-20111127
whereas in the online version, tinymce is called using a js file
wp-includes/js/tinymce/tiny_mce.js?ver=345-20111127
This maybe means there's a difference in the code generated with both js and php file? (I checked both file outputs and I can see they look identical) or maybe because the local version is run in a WordPress mulitisite environment while the live one is standalone WordPress website?
Any idea?
// set content body if ( typeof(tinymce) == 'object' ) { if (tinyMCE.EditorManager.activeEditor ) { tinyMCE.EditorManager.activeEditor.execCommand('mceSetContent', false, $("#gzr_post_body").val().replace(/\n/g,"<br>")); } else { console.log('tinyMCE.EditorManager.activeEditor is not defined'); } } else { console.log('tinymce is not defined'); }– numediaweb Jan 13 at 14:51