Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top