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