Trent Richardson Datetimepicker无法正常工作

时间:2015-06-09 12:36:37

标签: jquery ruby-on-rails ruby datetimepicker

我在我的rails项目中包含了Trent Richardsons Datetimepicker但在加载页面后,包含datetimepicker的div已经显示。我认为它应该只在点击时显示,而不是之前显示。这是一个截图:

enter image description here

包含datetimepicker的代码:

<div class="form-group col-xs-6 col-sm-6 col-md-6 col-lg-6" id="event_enddate_group"> <div class="controls"> <%= f.label :enddate, :class => 'control-label' %> <div class='input-group date' id='datetimepicker_enddate'> <%= f.text_field :enddate, :class => 'form-control'%> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span> <script type="text/javascript"> $(function () { $('#event_enddate').datetimepicker({ locale: 'nl' }); }); </script> </div> </div> </div>

更改了上面的代码。现在datetimepicker正在显示正确的时刻,但布局仍然是错误的。

1 个答案:

答案 0 :(得分:0)

<div class="form-group col-xs-6 col-sm-6 col-md-6 col-lg-6" id="event_enddate_group">
        <div class="controls">
          <%= f.label :enddate, :class => 'control-label' %>
          <div class='input-group date' id='datetimepicker_enddate'>
            <%= f.text_field :enddate, :class => 'form-control event_enddate' %>
            <span class="input-group-addon">
              <span class="glyphicon glyphicon-calendar"></span>
            </span>
            <script type="text/javascript">
                $(function () {
                    $('.event_enddate').datetimepicker({
                        locale: 'nl'
                    });
                });
            </script>
          </div>
        </div>
      </div>

在执行任何jquery或javascript功能时始终使用class而不是id