2016-03-25 10 views
0

Bootstrap3 DatetimepickerをRails4アプリに適用したいと思います。Rails 4 x Bootstrap 3 Datetimepicker:デザインが良くない

しかし、レイアウトはこのページのように(質問画像の途中で)良くありません。 Rails 4 x Bootstrap 3 Datetimepicker: replace default datetime_select with datetimepicker

あなたが私に何か示唆を与えることができれば幸いです。

_xxx_form.html.erb

<%= simple_nested_form_for(@schedule) do |f| %> 
    <div class="input-group date" id="datetimepicker"> 
    <%= f.label :departure_date %> 
    <%= f.text_field :departure_date, class: 'form-control' %> 
    <span class="input-group-addon"> 
     <span class="glyphicon-calendar glyphicon"></span> 
    </span> 
    </div> 
    <script type="text/javascript"> 
    $(function() { 
     $('#datetimepicker').datetimepicker({format:'MMM-DD-YYYY'}); 
    }); 
    </script> 
    ... 

を解決しよう!

レイアウトは、f.label<div class="input-group date" id="datetimepicker">の外に移動した後に予想通りでした。

... 
    <%= f.label :departure_date %> 
    <div class="input-group date" id="datetimepicker"> 
    <%= f.text_field :departure_date, class: 'form-control' %> 
    ... 
+0

カレンダーを表示し、入力フィールドをクリックし、私の質問の下部にある自分の質問を解決しました。 – SamuraiBlue

答えて

0

私はJS

この単純素敵

<%= f.text_field :departure_date, class: 'form-control', id: 'datepicker'%> 

思い

$(function() { 
    $("#datepicker").datepicker({ 
     dateFormat: "yy-mm-dd" 
    }); 
}); 

だけ

関連する問題