我用Rails 3.2版本和Ruby 1.9.3日期選擇器不顯示正確的字段
我想要一個的form_tag一個datepicker領域內作出。 在我的GemFile中,我添加了gem'jquery-rails',gem'jquery-ui-rails'和gem'jquery_datepicker'。 在軌控制檯我用命令:軌產生的jQuery:安裝--ui
的application.js看起來是這樣的:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require jquery_ui.all
//= require_tree .
$(function() {
$(".datepicker").datepicker({dateFormat: "yy/mm/dd"});
});
Application.css:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*= require_jquery.ui.all
*/
And in the view:
<%= form_tag url: {action: 'do_something'} do |f| %>
<%= text_field_tag :birth_date, '', :class => "datepicker" %>
<%= submit_tag "Do something man!"%>
<% end %>
有什麼爲form_tag正確調用datepicker函數?
UPDATE1:在Chromium瀏覽器,調試$( 「日期選擇器」)返回null .. 編輯我的文件(感謝Sagar.Patil)
FinalUpdate:我還沒有找到有關這個問題的解決方案。嘗試併成功地使用bootstrap-datepicker。
你可以參考這個[http://apidock.com/rails /v3.2.13/ActionView/Helpers/DateHelper/date_select] –
一件小事:我認爲最好的做法是將require_tree。語句(帶點的語句)保留在所有require語句的底部。 – zwippie