The tales of Wordpress & jQuery - '$ is not a function', said the console...

Fu

Once upon a time, there was an OpenSource Blog-System around the Internetz. It seemed to be a very handsome one, almost everybody got along with it quite well - as long as you didn't have to look at what's inside of it. When I once did, it was disturbing: The whole thing was so messed up.

However, the reason why I'd had to look at Wordpress' code was the following one: My browser tried to convince me, that '$ is not a function'. Well, it certainly is, I thought. And I was kind of right, as well. The major problem is, when it comes to using other JavaScript Frameworks along with Wordpress, Wordpress already comes with a handy one itself: It is called 'Prototype'. And the $ function already is reserved for Prototype stuff.

Trial & Error combined with the magic power of Google did it. In case you're trying to run jQuery stuff along with Wordpress' Prototype stuff, don't use the $ function for your jQuery code anymore. Instead of the $, try to use jQuery. Sounds strange? How to do that? Well, it is quite simple, simple as that:

 $().ready( function() {
       $("#aawwwcmon").dosth();
 });

simply becomes

 jQuery().ready( function() {
       jQuery("#aawwwcmon").dosth();
 });

This did it for me, and it hopefully will do for you as well!

 

Neueröffnung!

Ein herzliches Grüß Gott und herzlich Willkommen zur Neueröffnung des Codestüberls, der feinen Küche für grobe Schnitzer!

Wir, das Team vom Codestüberl, versorgen Sie mit allen möglichen Spezialitäten aus der Welt der Computer und der Programmierung! Bei uns dürfen Sie herzhaft lachen, boshaft lachen, schadenfroh schmunzeln, sich fremdschämen und manchmal auch notgedrungen weinen! Wir laden Sie ein, von unserem reichhaltigen Angebot an Kuriositäten aus den Tiefen des Internets zu schlemmen. Wir haben unter anderem folgende Schmankerl im Angebot:

  • Deutscher Behördenbraten mit Inkompetenzkartoffeln
  • Ragout mit ganzen Großkonzernen und Sicherheitsmängeln
  • Entwicklerteller mit Tutorials nach Art des Hauses

Von unserer Getränkekarte empfehlen wir Ihnen:

  • Programmiersprachencocktail inkl. Infusion zur Abwehr von Kreislaufzusammenbrüchen
  • Maß Failbier mit Kopfschmerzgarantie

Abonnieren Sie uns doch einfach, damit wir Sie bequem und kostenfrei mit neuen Köstlichkeiten aus der Computerwelt versorgen können! Sollten Sie jemals den dringenden Wunsch nach einem ernsthaften Kopfschütteln verspüren, schauen Sie doch bei uns vorbei! Wir servieren gut und gerne!

Posterous Theming Syntax Error in 'js_show_on_click' - got , more-tags-listing,

Archive