views:

676

answers:

3

I'm having some trouble getting jQuery to play nice with DokuWiki - has anyone already done this successfully?

At the moment, including jQuery reuslts in all sorts of JS functionality breaking, and I'm having trouble tracking down the source of the problem. What are some things to look for that tend to conflict with jQuery?

+4  A: 

You can usually avoid any jQuery conflicts by using the following right after you load jquery.js:

jQuery.noConflict();

Then, it won't overwrite the $ variable, which is most often the source of trouble in these JS library conflicts. You'll need to call jQuery functions using jQuery, though. Examples:

jQuery(function() { ... }); // $(function ...
jQuery(".klass").hide();    // $(".klass" ...
Ben Alpert
+9  A: 

I'm not familiar with DokuWiki personally but if something is breaking just when you include jQuery then it's probably a conflict with the '$' variable in jQuery. You can use jQuery's noConflict method to get around that, more information here: http://docs.jquery.com/Using_jQuery_with_Other_Libraries

See also this Stack Overflow post: http://stackoverflow.com/questions/134572/jquery-prototype-conflict

John Resig
AFAIK, the only items added to the global namespace are $ and jQuery (which are synonyms). Using noConflict() reduces this to jusy jQuery. Hopefully, DokuWiki doesn't reference anything named jQuery in the global namespace ;)
Adam Bellaire
+4  A: 

There's also a plugin that adds JQuery to DokuWiki: http://www.dokuwiki.org/plugin%3Ajquery

Andreas Gohr