Ruby on rails 日期选择器未显示正确的字段

Ruby on rails 日期选择器未显示正确的字段,ruby-on-rails,ruby-on-rails-3,jquery-ui,ruby-on-rails-3.2,Ruby On Rails,Ruby On Rails 3,Jquery Ui,Ruby On Rails 3.2,我使用的是Rails版本3.2和Ruby 1.9.3 我试图在表单标记中创建一个日期选择器字段。 在我的gem文件中,我添加了gem‘jquery rails’、gem‘jquery ui rails’和gem‘jquery_datepicker’。 在rails控制台中,我使用了命令:railsgeneratejquery:install--ui Application.js如下所示: // This is a manifest file that'll be compiled into a

我使用的是Rails版本3.2和Ruby 1.9.3

我试图在表单标记中创建一个日期选择器字段。 在我的gem文件中,我添加了gem‘jquery rails’、gem‘jquery ui rails’和gem‘jquery_datepicker’。 在rails控制台中,我使用了命令:railsgeneratejquery:install--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 %>
/*
*这是一个清单文件,将被编译成application.css,其中将包含所有文件
*如下所列。
*
*此目录中的任何CSS和SCSS文件、lib/assets/stylesheets、vendor/assets/stylesheets、,
*或供应商/资产/插件样式表(如果有),可以在此处使用相对路径进行引用。
*
*您可以自由地将应用程序范围的样式添加到此文件,它们将显示在
*已编译的文件,但通常最好为每个样式范围创建一个新文件。
*
*需要自己
*=需要一棵树。
*=需要_jquery.ui.all
*/
并且认为:
“日期选择器”%>
form_标记的datepicker函数的正确调用是什么

更新1:在chromium浏览器中,调试$(“.datepicker”)返回空值。。 编辑我的文件(谢谢Sagar.Patil)

最后更新:我还没有找到解决这个问题的方法。已尝试并成功使用引导数据采集器。

进行此更改 application.js

//= require jquery.ui.all
$(function() {
    $(".datepicker" ).datepicker({dateFormat: "yy/mm/dd"});
});
application.cs

 *= require jquery.ui.all
查看文件

<%= text_field_tag :birth_date,'', :class => "datepicker" %>
“日期选择器”%>

您可以参考这个[一件小事:我认为最好的做法是将
require_树。
语句(带点的语句)放在所有require语句的底部。它输出一个文本字段,其中包含:{:class=>“.datepicker”}签出我已经编辑了我的答案。我没有意识到它是一个文本字段标记。我以为它是一个文本字段。越来越近了。它不只是输出一个空文本字段。如果我在里面单击,什么都不会发生。你是否在gem中添加了
gem'jquery ui rails'
,并重新启动rails服务器,然后再尝试一件事“datepicker”%>没有”在“datepicker”之前,我有jquery ui rails。但它是4.0.4版。也许这就是问题的原因?在gem文件中,我写了“gem jquery ui rails”