我遇到一个问题,即常规日期选择器以此格式'2017-09-12 22:49:27'
更新rails侧的值,但我尝试使用datetimepicker并且不更新值,它会使用格式更新文本字段:M/DD/YYYY
但不是param中的实际值,因为我需要'2017-09-12 22:49:27'
格式,但它保持与当前MM/DD/YYYY
相同的值,就像为文本字段加载的那样,我是当我尝试查看当前值时获取undefined
值:
var selectedDate = $("#from").find(".active").data("day");
这是ruby代码
= text_field_tag :from_js, l((params[:from].to_datetime or @item.created_at), format: :american_no_time), class: 'form-control input-sm datetimepicker', id: 'from'
= hidden_field_tag :from, l((params[:from].to_datetime or @item.created_at), format: :american_no_time)
= text_field_tag :to_js, l((params[:to].to_datetime or Time.zone.now.to_datetime), format: :american_no_time), class: 'form-control input-sm datetimepicker', id: 'to'
= hidden_field_tag :to, l((params[:to].to_datetime or Time.zone.now.to_datetime), format: :american_no_time)
这是当前的javascript:
var maxDate = new Date();
var minDate = $("#from").val();
$(function () {
$('#from').datetimepicker({
format: "M/D/YYYY",
minDate: minDate,
maxDate: maxDate,
pickTime: false
});
$('#to').datetimepicker({
format: "M/D/YYYY",
minDate: minDate,
maxDate: maxDate,
pickTime: false
});
});
任何想法或建议都将不胜感激