Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 将引导日期选择器rails添加到表单中的日期选择_Ruby On Rails_Ruby On Rails 3_Forms_Twitter Bootstrap_Datepicker - Fatal编程技术网

Ruby on rails 将引导日期选择器rails添加到表单中的日期选择

Ruby on rails 将引导日期选择器rails添加到表单中的日期选择,ruby-on-rails,ruby-on-rails-3,forms,twitter-bootstrap,datepicker,Ruby On Rails,Ruby On Rails 3,Forms,Twitter Bootstrap,Datepicker,因此,我有一个使用“日期选择”的表单,它为每个使用的日期选择(年、月和日)呈现三个选择框 相反,我想使用datepicker,我已经按照说明进行了操作。但是,我不知道如何在视图的表单中实际实现datepicker 我在application.js中使用以下行 $('.datepicker').datepicker() …所以我想我需要给选择框类datepicker <%= form_for @project do |f| %> <div class="text_fie

因此,我有一个使用“日期选择”的表单,它为每个使用的日期选择(年、月和日)呈现三个选择框

相反,我想使用datepicker,我已经按照说明进行了操作。但是,我不知道如何在视图的表单中实际实现datepicker

我在application.js中使用以下行

$('.datepicker').datepicker()
…所以我想我需要给选择框类datepicker

<%= form_for @project do |f| %>
    <div class="text_field">
        <%= f.label :title%>
        <%= f.text_field :title%>
    </div>
    <div class="text_field">
        <%= f.label :description%>
        <%= f.text_field :description%>
    </div>
    <div class="dropdown">
        <%= f.label :start_date%>
        <%= date_select :start_date, :startdate %>
    </div>
    <div class="dropdown">
        <%= f.label :end_date%>
        <%= date_select :end_date, :enddate%>
    </div>
    <div class="select">
        <%= f.label :title%>
    </div>
    <div class="submit">
        <%= f.submit "Spara" %>
    </div>
<% end %>

试试:

<%= date_select :start_date, :startdate , :class => 'datepicker' %>
正如gem的安装指南中所述,您应该确保在
应用程序.css
应用程序.js
中都需要
它。还有一件更重要的事情:在
projects.js.coffee
中,确保加载DOM,如下所示:

jQuery ->
  $('.datepicker').datepicker()

谢谢你的回答。现在试过了,但什么也没发生。更奇怪的是,当我检查源代码时,该类甚至没有添加到选择框中:/确保所有
require
命令都在那里,并用
$(function(){…})包装日期选择器调用日期字段仍然为空?日期字段仍然为空?
jQuery ->
  $('.datepicker').datepicker()