I'm running rails 3 on localhost and was getting the error
Uncaught TypeError: Object [object Object] has no method 'datepicker'
after following railscasts http://railscasts.com/episodes/213-calendars, and putting both lines below into my application.html.erb file
<%= stylesheet_link_tag "http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/redmond/jquery-ui.css", "application" %>
<%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js", "application" %>
I actually solved this error by downloading jquery-ui.min.js file and putting it in my javascripts project folder, and replacing one of the lines, to the result below :
<%= stylesheet_link_tag "http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/redmond/jquery-ui.css", "application" %>
<%= javascript_include_tag "application" %>
I also do not understand why i need to put my datepicker function inside my application.js :
$(function() {
$('#start_date').datepicker();
$('#end_date').datepicker();
})
and cannot put it on my users.js.coffee file with just the lines :
$('#start_date').datepicker();
$('#end_date').datepicker();
Anyone can explain why adding the js file locally solved this error, and why i cannot put my datepicker into my local coffee file, or if i can, can you please tell me how?
Thank you