将日期范围选择器的开始日期设置为空白

编程入门 行业动态 更新时间:2024-10-28 16:20:42
本文介绍了将日期范围选择器的开始日期设置为空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个基于 www.daterangepicker 的日期范围选择器和我的日期范围选择器想要将开始日期设置为空.这将适用于我想做的事情.

I have a daterange picker based on www.daterangepicker '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')); }

更多推荐

将日期范围选择器的开始日期设置为空白

本文发布于:2023-10-30 13:35:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1543006.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期   设置为   空白   选择器

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!