问题描述
我有一个基于 http://www.daterangepicker.com 的日期范围选择器和我的日期范围选择器想要将开始日期设置为空.这将适用于我想做的事情.
I have a daterange picker based on http://www.daterangepicker.com 's daterange picker and I want to set the start date to empty. This will work for what I want to do.
我正在使用文本输入字段来获取日期
I'm using an text input field to get the dates
</span><input type="text" class="form-control" id="reservation" />
该站点上有一个设置输入最初为空"的示例,但我无法使其正常工作.基本上我不知道该在哪里设置它.
On the site there is an example of setting "Input Initially Empty" but I couldn't get it to work. Basically I don't know where to set it as it seems.
我的日期范围选择器在局部视图中,并被另一个视图调用.页面脚本是在调用部分脚本的视图中设置的.在daterangepicker.js脚本上,我找到了以下几行;
My daterange picker is inside a partial view and it called by another view. Page scripts are set in the view which calls the partial one. On the daterangepicker.js script I found these lines;
//default settings for options
this.parentEl = 'body';
this.element = $(element);
this.startDate = moment().startOf('day');
this.endDate = moment().endOf('day');
this.minDate = false;
this.maxDate = false;
this.dateLimit = false;
this.autoApply = false;
this.singleDatePicker = false;
this.showDropdowns = false;
this.showWeekNumbers = false;
this.timePicker = false;
this.timePicker24Hour = false;
this.timePickerIncrement = 1;
this.timePickerSeconds = false;
this.linkedCalendars = true;
this.autoUpdateInput = true;
this.ranges = {};
据我所知,它们基于moment.js.我尝试操作this.startDate
,但无法将其设置为空白值.使用this.startdate = null
会使整个日期范围选择器停止工作,因此我想我需要类似moment.js的空日期之类的东西.或完全不同的东西.
As far as I can tell they are based on moment.js. I tried manipulating this.startDate
but couldn't manage to set it to a blank value. using this.startdate = null
made the whole date range picker stop working so I guess I need something like empty date equivalent of moment.js. Or something entirely different.
有人可以告诉我该怎么做吗?
Can anyone show me how to do it?
推荐答案
autoUpdateInput: false
function (chosen_date) {
$('.form-datetime').val(chosen_date.format('YYYY-MM-DD'));
}
这篇关于将日期范围选择器的开始日期设置为空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!