Closed thebennos closed 7 years ago
This module depends on JQuery. Is Drupal loading JQuery before TinyMCE?
You might need to load JQuery as a dependency:
https://www.drupal.org/node/2269515
Edit: Since you are using version 7, not 8:
https://www.drupal.org/docs/7/theming/working-with-javascript-and-jquery
This might help too:
https://stackoverflow.com/questions/8886614/uncaught-referenceerror-jquery-is-not-defined
Jquery is loaded, version 1.10-
I understand jquery is loaded, but there is order of how things are loaded.
Make sure Jquery is loaded before tinymce.
What is most likely happening is this:
-tinymce loaded -jquery loaded -document ready
This is why it works on document ready but not prior.
Just put jquery loading on top.
The loading order is correct, because tinymce is loaded and works and the other plugins are loaded in the same way. In the drupal7 wysiswyg modul, the plugin is declared like the other plugins. Loading the codesample plugin works correctly.
I wrapped all inside this
// We define a function that takes one parameter named $. (function ($) { // Use jQuery with the shortcut: console.log($.browser) // for example; // Here we immediately call the function with jQuery as the parameter. }(jQuery));
And the first error messages are gone.
Now I get, when the TinyMCE is loaded,
Uncaught ReferenceError: LanguageTool is not defined
at c.
Wrapping your complete code is maybe not a good idea. I try to wrap the function, where you use the jquery shortcut.
Feedback for you. I replaced the jquery shortcut "$" with jQuery in the complete JS scripts and it works.
So the usage with jQuery make it more compatible with Drupal. In other CMS there is the same problem, that jquery is available but not the shortcut, so you should think of a switch .
The usage of jQuery vs $ is due to noConflict.
https://api.jquery.com/jquery.noconflict/
By the way you are using 0.31 or 0.32 now? (I did a minor change to 0.32 which may help, though it might not)
I think 0.31. I downloaded it and made my changes locally.
Okay, I did a fix for noConflict, try version 0.33 or newer
I try to integrate your plugin into drupal 7 (wysiwyg module with tinyMCE installed). Changed some of the drupal module code and the plugin is correctly loaded if the tinymce is initiated at a texfield.
The javascript of the plugin looka little bit problematic.
languagetool.min.js:90 Uncaught TypeError: $ is not a function at new LanguageTool (/sites/all/libraries/tinymce/js/tinymce/plugins/languagetool/include/languagetool.min.js:90:17) at c. (/sites/all/libraries/tinymce/js/tinymce/plugins/languagetool/plugin.min.js:121:11)
I am not really the best at JS coding, but looks in the drupal eviroment the $ is only available after the document is fully loaded, document.ready.
Hope we can get it more robust and working on Drupal 7.
Let me know if If can help.