Ruby on Rails 4 bootstrap datetimepicker设置

时间:2016-02-29 19:20:51

标签: ruby-on-rails twitter-bootstrap

我正在努力让bootstrap datetimepicker工作。有人可以帮我安装吗?

的application.js

//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require_tree .
//= require nested_form_fields
//= require bootstrap-datepicker
//= require bootstrap-datepicker/core
//= require bootstrap-datepicker/locales/bootstrap-datepicker.ru.js
//= require bootstrap-datepicker/locales/bootstrap-datepicker.et.js
//= require moment
//= require bootstrap-datetimepicker

trainings.coffee

$('#training_start_time').datetimepicker({ format: 'dd/mm/yyyy hh:mm' });

视图

= form_for @training do |f|
...
    = f.text_field :start_time, :data => { :provide => 'datetimepicker', date_format: 'dd/mm/yyyy hh:mm' }, :value => f.object.start_time.strftime("%d/%m/%Y %H:%M")  

1 个答案:

答案 0 :(得分:0)

尝试将您的javascript代码转换为咖啡脚本样式。

$('#training_start_time').datetimepicker format: 'dd/mm/yyyy hh:mm'