我运行在本地主机上轨3和以下railscasts http://railscasts.com/episodes/213-calendars后得到的错误遗漏的类型错误:对象的翻译:有没有方法“日期选择器”
Uncaught TypeError: Object [object Object] has no method 'datepicker'
,并把下面两行到我的应用程序.html.erb文件
<%= 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" %>
我居然通过下载jQuery的ui.min.js文件,并把它在我的JavaScript的项目文件夹,并更换线路之一,下面的结果解决了这个错误:
<%= stylesheet_link_tag "http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/redmond/jquery-ui.css", "application" %>
<%= javascript_include_tag "application" %>
我也弄不明白,为什么我需要把我的日期选择器功能,我的application.js里面:
$(function() {
$('#start_date').datepicker();
$('#end_date').datepicker();
})
,不能把它放在我的users.js.coffee文件只用几行:
$('#start_date').datepicker();
$('#end_date').datepicker();
任何人都可以解释为什么在本地添加js文件解决了这个错误,以及为什么我不能把我的datepicker放到我的本地咖啡文件中,或者如果我可以,请告诉我怎么做?
谢谢
+1解释如何解决“没有方法'datepicker'”错误。 – dimir 2012-10-16 22:01:15