Pages

Tuesday, May 8, 2012

Jquery is not defined

You might get this error while integrating jquery in your appplication.Scripts will not get invoked.

I have to include Datepicker for a field in a page.

var $j = jQuery.noConflict();
$j(document).ready(function($) {
});

Got the error "jQuery is not defined"

Just changed order of the script which i included in the application. The error got resolved :)-

<%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" %>

<%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/jquery-ui.min.js" %>

<%= stylesheet_link_tag "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/themes/base/jquery-ui.css" %>

The order in which you load your scripts is important


2 comments:

  1. Well, you have mentioned only one cause of this error but there are many other reasons as well. Thought of sharing with you.

    http://jquerybyexample.blogspot.com/2012/03/various-reasons-and-solutions-of-jquery.html

    ReplyDelete
  2. Really useful stuff .Never had an idea about this, will look for more of such informative posts from your side.. Good job...Keep it up Very nice tech blog

    ReplyDelete