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.
我有一个基于http://www.daterangepicker.com的日期范围选择器的日期范围选择器,我想将开始日期设置为空。这将适用于我想要做的事情。
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.
在网站上有一个设置“输入最初为空”的例子,但我无法让它工作。基本上我不知道在哪里设置它似乎。
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;
我的日期范围选择器位于局部视图中,并由另一个视图调用。页面脚本在视图中设置,调用部分脚本。在daterangepicker.js脚本中我找到了这些行;
//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 = {};
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.
据我所知,他们是基于moment.js。我试过操纵this.startDate但无法设法将其设置为空值。使用this.startdate = null使整个日期范围选择器停止工作,所以我想我需要类似于moment.js的空日期。或者完全不同的东西。
Can anyone show me how to do it?
谁能告诉我怎么做?
1 个解决方案
#1
6
autoUpdateInput: false
function (chosen_date) {
$('.form-datetime').val(chosen_date.format('YYYY-MM-DD'));
}
#1
6
autoUpdateInput: false
function (chosen_date) {
$('.form-datetime').val(chosen_date.format('YYYY-MM-DD'));
}