Subscribe to Developer OraclesNews FeedSubscribe to Developer OraclesComments — Translate page:        

jQuery : Error: $(document).ready is not a function — Sure!

October 19, 2008
Filed under JavaScript

This error message appears only if another framework is in conflict with the almighty jQuery. For example You try to use Prototype/Scriptaculous for Lightbox but you also need Thickbox for something else, which requires jQuery.

Since no framework is compatible with another framework, you have to find a workaround to get things working.

And here comes jQuery in your help. The jQuery team was smart enough to realize that there will be conflicts between frameworks, especially the $ will cause massive headaches since it’s the basic of each framework. $ is the shortcut for the word “jQuery”

So, they invented jQuery.noConflict();. This will let you to replace the $ with the word jQuery, in all your code. So, when you need to call this: $(document).ready(function(){ … You simply replace the $ as I said above: jQuery(document).ready(function(){ …, don’t forget to call jQuery.noConflict(); before this.

So, when you use the noConflict() function, your code should look something like this:

<head>
  
  
  
</head>

World saved again, now you can use 2 frameworks together.

Share or Bookmark this post: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Ask
  • Bloglines
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • Slashdot
  • SphereIt
  • Technorati

Possible related posts (automatic):

Related posts brought to you by Yet Another Related Posts Plugin.

Comments

4 Comments on " jQuery : Error: $(document).ready is not a function — Sure! "

  1. Juanlu_001 on Sat, 29th Nov 2008 11:47 am  

    This saved me, thank you very much!! :)

  2. Thomas I on Sat, 29th Nov 2008 1:07 pm  

    With much pleasure Juanlu

  3. jonycus on Mon, 1st Dec 2008 6:31 pm  

    I lost about a day with this problem… and guess what.. this WORKED!!! I owe you a case of beer man..

    Cheers!!!

  4. Andy Forbes on Fri, 5th Dec 2008 12:48 pm  

    Mirroring previous comments - wish I had found your site earlier, absolutely spot on, why cannot jquery offer this on their site more prominently.

    Much Thanks, such a simple fix for a giant thorn in my side!

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

If you want to use your OpenID, fill out the field labeled "Website" with the OpenID URL. The other fields may remain empty.

Subscribe without commenting