私たちのアプリケーションにはDaterangepickerが使用されています。今日の日付または以前の入力の日付を選択できません
multitrip日付ピッカーコンポーネント(3つの入力フィールド)
- TripOneの作成 - 選択した日付(例:2月19日)
- TripTwoを - 'TripOne' 選択した日付から開始する必要があります。
- TripThree - 選択した「TripTwo」から開始する必要があります。
上記のことは問題ありません。
ただし、以下の問題はこのプラグインでは機能しません。
- TripOne - 今日の日付(動作しない)
- TripTwoを選択 - 2月20日はTripOneに選択した場合、私はTripTwoに同じ2月20日を選択することができ傾きます。
- TripThree - TripTwoに似ています。
JS:
var nowDate = new Date();
var today = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), 0, 0, 0, 0);
var maxLimitDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate()+360, 0, 0, 0, 0);
$('input[name="tripOne"]').daterangepicker({
"autoApply": true,
"autoUpdateInput": false,
"singleDatePicker": true,
"minDate": today,
"maxDate": maxLimitDate,
"locale": {
format: 'DD MMM YYYY'
}
},function(start) {
$("#tripOne").val(start.format('DD MMM YYYY'));
$('#tripOne').parent().parent().removeClass('has-error');
var returnTripStartDate = new Date(Date.parse(start));
$('input[name="tripTwo"]').daterangepicker({
"autoApply": true,
"autoUpdateInput": false,
"singleDatePicker": true,
"minDate": returnTripStartDate,
"maxDate": maxLimitDate,
"locale": {
format: 'DD MMM YYYY'
}
},function(end) {
$("#tripTwo").val(end.format('DD MMM YYYY'));
$('#tripTwo').parent().parent().removeClass('has-error');
var returnTripStartDate2 = new Date(Date.parse(start));
$('input[name="tripThree"]').daterangepicker({
"autoApply": true,
"autoUpdateInput": false,
"singleDatePicker": true,
"minDate": returnTripStartDate2,
"maxDate": maxLimitDate,
"locale": {
format: 'DD MMM YYYY'
}
},function(end) {
$("#tripThree").val(end.format('DD MMM YYYY'));
$('#tripThree').parent().parent().removeClass('has-error');
});
$(function() {
$('.calendar.right').show();
});
});
$(function() {
$('.calendar.right').show();
});
$('input[name="tripOne"]').on('apply.daterangepicker', function(ev, picker) {
$(this).val(picker.startDate.format('DD MMM YYYY'));
});
$('input[name="tripTwo"]').on('apply.daterangepicker', function(ev, picker) {
$(this).val(picker.startDate.format('DD MMM YYYY'));
});
$('input[name="tripThree"]').on('apply.daterangepicker', function(ev, picker) {
$(this).val(picker.startDate.format('DD MMM YYYY'));
});
});
$(function() {
$('.calendar.right').show();
});
デベロッパーコンソールでエラーが発生する可能性はありますか? – ymz
エラーなしボス..唯一のもののロジックがありません。次の入力フィールドで '選択した日付'または '今日の日付'を再選択できます。 – TDG
これは私の最新の更新コードです。 https://jsfiddle.net/jkenluv/z9tgdh7k/7/ – TDG