jquery ui多日期选择器|选择所有月份的日期

时间:2022-09-27 20:37:34

jquery ui多日期选择器|选择所有月份的日期

Library used: http://multidatespickr.sourceforge.net/

使用的库:http://multidatespickr.sourceforge.net/

I want to select all the dates of a particular month when clicked on the month title.

我想在点击月份标题时选择特定月份的所有日期。

Suppose I click on "January 2016", all the dates should be selected under January including the existing dates.

假设我点击“2016年1月”,所有日期应在1月份选择,包括现有日期。

codepen link :-- http://codepen.io/hardiksh/pen/zqmgBw

codepen链接: - http://codepen.io/hardiksh/pen/zqmgBw

i write below code :--

我写下面的代码: -

$( document .delegate( ".selectMonth", "click", function() {

var thisMonth = $(this).attr("data-month";
var thisYear = $(this).attr("data-year";

thisMonth = parseInt(thisMonth);
thisYear = parseInt(thisYear);

thisMonth = thisMonth +1;

lastDay = new Date(thisYear, thisMonth, 0).getDate();

if(thisMonth < 9){
    thisMonth = '0'+thisMonth;
}

allDates3 = [];

for (i = 1; i <= lastDay; i++) {

    if(i < 9){
        i = '0'+i;
    }

    allDates3.push(thisMonth+'/'+i+'/'+thisYear);
}



$('#full-year').multiDatesPicker('destroy');

$('#full-year').multiDatesPicker({
addDates: allDates3,
numberOfMonths: [3,4],
defaultDate: '1/1/'+y
});
});

1 个解决方案

#1


0  

I don't know why, maybe a bug in the picker or a setting/option that I can't figure out this removed it. I don't see why it's picking it.

我不知道为什么,也许是挑选者或设置/选项中的一个错误,我无法弄清楚这个删除它。我不明白它为什么选择它。

$('#full-year').multiDatesPicker('destroy');
        $('#full-year').multiDatesPicker({
            addDates: allDates3,
            numberOfMonths: [3,4],
            defaultDate: '1/1/'+y
        });
    $('#full-year').multiDatesPicker('removeIndexes',0);

#1


0  

I don't know why, maybe a bug in the picker or a setting/option that I can't figure out this removed it. I don't see why it's picking it.

我不知道为什么,也许是挑选者或设置/选项中的一个错误,我无法弄清楚这个删除它。我不明白它为什么选择它。

$('#full-year').multiDatesPicker('destroy');
        $('#full-year').multiDatesPicker({
            addDates: allDates3,
            numberOfMonths: [3,4],
            defaultDate: '1/1/'+y
        });
    $('#full-year').multiDatesPicker('removeIndexes',0);