Tinymce jquery plugin error tinymce is not a function

I am using the tinymce jquery plugin and trying to access the api after initializing the tinymce instance above the text box.

In this example, I have a hide button that, when clicked on, should hide the tinymce editor, but instead I get an error.

<html> <head> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> <script type="text/javascript" src="js/tinymce/jquery.tinymce.js"></script> <script type="text/javascript" src="js/test.js"></script> </head> <body> <div><textarea id="textEditor" class="tinymce" disabled="disabled"></textarea></div> <input type ="button" id="hide" value="Hide tinymce"> </body> </html> 
 $(document).ready(function(){ //textEditor $("#textEditor") .tinymce({ // Location of TinyMCE script script_url : 'js/tinymce/tiny_mce.js', theme : "advanced", theme_advanced_buttons1 : "bold,italic,underline,", theme_advanced_resizing : false }) //... see below ...// }); 

Update . I now have 2 versions, one of which works by wrapping $ ("# textEditor"). tinymce (). hide (); line in the click function, and one that gives me tinyMCE, not defined only by the line itself.

Works:

 $("#hide").click(function(){ $("#textEditor").tinymce().hide(); }) 

Does not work:

  $("#textEditor").tinymce().hide(); //error tinyMCE is not defined 
+4
source share
2 answers

You can try

 tinymce.get("textEditor").hide(); 

To ensure that you are using the correct tinymce identifier, you can warn all tinymce identifiers present on your page using

 for (var i = 0; i < tinymce.editors.length; i++) { alert(tinymce.editors[i].id); } 

EDIT:

It:

 /** Option Block A error **/ // $("#textEditor").tinymce().hide(); //error tinyMCE is not defined /** Option Block A error **/ 

does not work because it will be called before the tinymce editor is initialized. There is currently no tinymce.get("textEditor") .

+4
source

I think the path to your jquery plugin is wrong, because the $ .tinymce () method is provided there. If the file is not found, then this method.

You should also make sure that the path specified inside the * script_url * field is valid, as the plugin will try to load it on the fly.

+1
source

All Articles