I am trying to introduce some jquery-ui widgets into a new Rails 3.1 app. When I add the hook for the datepicker, I get an error TypeError: 'undefined' is not a function in the browser’s debugging console
permits.js.coffee:
$ ->
$ ('.datepicker').datepicker()
application.js:
//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require_tree .
generated HTML snippet:
<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery-ui.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/permits.js?body=1" type="text/javascript"></script>
<script src="/assets/application.js?body=1" type="text/javascript"></script>
To troubleshoot, I saved the generated HTML and removed the application.js script import and it worked fine.
Why is the error happening when trying to call the datepicker() on the input.datepicker element?