我正尝试在我的simple_form中使用Jquery日期选择器。
我有一个字段
<%= simple_form_for @customer, :html => { :class => 'form-horizontal' } do |f| %>
<%= render "shared/error_messages", :target => @customer %>
<%= f.input :start_lease_date, :as => :text %>
<% end %>
我已经安装了Jquery-ui,并在我的application.js中添加了require选项
//= require jquery.ui.datepicker
我还在application.css中添加了require
*= require jquery.ui.datepicker
我还添加了包含以下内容的customer.js.coffee文件
jQuery ->
$('#customer_start_lease_date').datepicker
dateFormat: 'yy-mm-dd'
但是,我的Start_lease_date字段仍然没有显示日期选择器
发布于 2012-12-06 13:20:13
我想下面的方法是可行的
<%= f.input :start_lease_date, :as => :text,
:input_html => { :class => 'date_picker' } %>
或
<%= f.input :start_lease_date, :as => :date_picker %>
发布于 2012-12-05 16:03:32
我会胡乱猜测一下,说你还没有运行/安装Jquery。Jquery-UI依赖于Jquery才能工作
发布于 2012-12-06 13:25:57
尝试将此文件添加到gem文件中...
group :assets do
# ...
gem 'jquery-ui-rails'
end
将其...and到您的应用程序/assets/javascripts/Application.js
//= require jquery.ui.datepicker
https://stackoverflow.com/questions/13722301
复制相似问题