Drupal, jQuery, Prototype, TinyMCE, oh my!

First, I posted the following feature request on drupal.org http://drupal.org/node/125030:

As things stand, if you want to use Drupal with the prototype library, you have a problem, in that both jQuery and Prototype use the $() function.

On the jQuery site, there is a workaround using (see http://docs.jquery.com/Using_jQuery_with_Other_Libraries ).

However: the recommended method doesn't work with jQuery 1.0.4:

var $j = jQuery.noConflict(); 
     // Use jQuery via $j(...)

because the noConflict() function isn't supported in 1.0.4!

What I did

In each of the files listed below, I did two things:

1. Added the following at the top:

var $jq = jQuery;

2. Change ever instance of $(...) to $jq(...)

Then, my prototype and jQuery got on fine.

List of files changed (in Drupal ./misc directory):


As of jQuery 1.1.x, the first line in the files will have to read:
var $jq = jQuery.noConflict();

My _feature request_ is... is there any way that in core, we could adopt a $jq or $drupal_jq override of the jQuery $() function? That way, Drupal will be compatible with Prototype and other libraries off the shelf!

Secondly, TinyMCE stopped working with scriptaculous.

So there, I followed the advice on the scriptaculous page (see http://wiki.script.aculo.us/scriptaculous/show/TinyMCE ):

<script type=”text/javascript” src=”prototype.js”></script>
<script type=”text/javascript” src=”tiny_mce.js”></script>
<script type=”text/javascript” src=”scriptaculous.js”></script>
<script type=”text/javascript”> tinyMCE.init({ config stuff here });



You're the best ! I finally can enable the autosuggest box from Script-A-Culous inside Drupal ! Thanks !

Good stuff!

Thanks Victor! This was quite helpful, and it good to see that this is being changed in D7.

In my case, I had to change the template file to include prototype before jQuery.js. And that was a pain, I think it should be possible to do that from the .module files without hacking into templates. Let me see if anybody has raised a request for this already...

Thanks once again!