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?

link|improve this question
another code variation // 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
feedback

closed as too localized by toscho May 2 at 16:11

This question is unlikely to ever help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. See the FAQ for guidance on how to improve it.

Browse other questions tagged or ask your own question.