JQuery plugin use gives “undefined” error

Chrome on Rails on Localhost. Here's a trimmed version of the page:

<!DOCTYPE html>
<head>
  <link href='http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css' rel='stylesheet'>
  <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js' type='text/javascript'></script>
  <script src='http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.js' type='text/javascript'></script>
  <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.3.1/jquery.cookie.min.js' type='text/javascript'></script>
  <meta content="authenticity_token" name="csrf-param" />
  <meta content="blahblah=" name="csrf-token" />
  <link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css" />
  <script src="/assets/application.js?body=1" type="text/javascript"></script>
  <meta name="viewport" content="width=device-width, initial-scale=1.0 maximum-scale=1.0">
</head>
<body data-action='index' data-controller='application'>
</body>

In the Chrome console (and in scripts farther down), $.cookie is undefined and $.cookie("a", "b") throws an error.

I've tried a few other CDNs, but same issue.

Edit: I'm trying things out in the Chrome Javascript console, which (I presume) runs after page load. I can check the "Resources" tab and see that the plugin has been loaded without issue. If I rearrange to link the plugin prior to Jquery, I get expected errors.

Answers


I checked the javascript files served by my application via the "resources" tab, and discovered that my application.js still had JQuery in it, so, presumably, it was redefining the JQuery without Coookie when the file was loaded.

This occurred because I switched from using gems to load JQuery to using an external CDN, but did not recompile (or delete) my assets.

Solved by removing the compiled assets from public/assets


Need Your Help

Cross-compiling on Windows and Linux

c

I am developing an application that will have to run on both Windows and Linux.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.