我正在跟踪这些链接以更改日期选择器的语言环境,但仍然无法正常工作。
加载页面时没有控制台日志错误。
链接:
https://eonasdan.github.io/bootstrap-datetimepicker/#using-locales
https://github.com/moment/moment
我的代码:
gemfile
gem 'momentjs-rails', '>= 2.9.0'
gem 'bootstrap3-datetimepicker-rails', '~> 4.17.47'
application.js
//= require moment
//= require bootstrap-datetimepicker
//= require moment/pt-br
dashboard.js
$(document).ready(function () {
$('.datetimepicker').datepicker({
locale: 'pt-br'
});
});
html.erb文件:
<div class='col-md-6'>
<div class="form-group">
<%= label_tag :initial_date, 'Data Inicial' %>
<div class='input-group date' id='initial_date'>
<%= text_field_tag(:initial_date, @filter&.initial_date, class: "form-control datetimepicker", id: "datetimepicker", autocomplete: "off") %>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
答案 0 :(得分:1)
如果您使用的是Rails 5> 0版本,我建议使用yarn,在这里您可以看到一些有用的链接:
http://nithinbekal.com/posts/yarn-rails/
yarn add moment
https://momentjs.com/