Need help with TinyMCE jQuery

I'm trying to get textarea formatting on my site using TinyMCE ... I'm a little new to integrating this kind of thing and can use some help.

I use their jQuery 3.4.x plugin found here .

I can not affect my text fields! They still look like regular text fields before integrating this code. I follow this guide .

Here is the script I'm using in my header (correct script_url ):

 <script src="tiny_mce/tiny_mce.js"></script> <script type="text/javascript" src="tiny_mce/jquery.tinymce.js"></script> <script type="text/javascript"> $(document).ready(function() { $('textarea.tinymce').tinymce({ theme : "simple" }); }); </script> 

And my text box:

 <textarea name="text" class="tinymce"></textarea> 

Thanks in advance.

+7
source share
1 answer

Since you are using jQuery, make sure you implement the jQuery $(document).ready() function:

 <script type="text/javascript"> $(document).ready(function() { $('textarea.tinymce').tinymce({ script_url : 'tiny_mce/tiny_mce.js', theme : "simple" }); }); </script> 

Edit # 1

Try downloading TinyMCE directly to make sure that there are no problems downloading the file:

 <script src="tiny_mce/tiny_mce.js"></script> 

Make sure this is loaded before $(document).ready() , but after loading jQuery. Then omit the script_url parameter for $.tinymce() .

Edit # 2

There is also the possibility that an error has occurred with jQuery or another script on the page. If in Safari or Chrome, right-click and select Inspect Element to check the JS console for errors.

Edit # 3

Double check that you are not mistaken in the tiny_mce script URL and that it loads correctly (clear the cache!) In the browser. Also, if you are using a different Javascript framework at the same time, make sure you run jQuery.noConflict() to make sure this is a problem.

Change # 4! I think I found the problem!

Someone who works on the blog obviously had the exact problem, as did you. His solution was to fully download and initialize tiny_mce.js before loading jQuery. Here's a link to the message so you can see how he did it.

+4
source

All Articles