2

次の方法を使用したいのですが、いくつかの日付の代わりにリストを使用します。

addDisabledDates: [today.setDate(1), today.setDate(3)]

これは私のカレンダーのコードです:

$( "#ExceptionDates")。multiDatesPicker({

    defaultDate: "+1w",
    firstDay: 1,
    dateFormat: "dd.mm.yy",
    numberOfMonths: 1,
    **addDisabledDates: ['06/19/2012','06/20/2012'],** (NOT working)
    onSelect: function ()
    {
        var dates = $("#ExceptionDates").multiDatesPicker('getDates');
        var html = '';
        $.each(dates, function (i, val)
        {
            html += '<input type="text" name="Dates" value="' + val + '">';
        });

        $("#SelectedDates").html(html);
    }
});

これは、日付を取得する方法です。

var getSelectedExceptionDates = function(callback)
{
    $.ajax({
        type: "POST",
        url: "/Route/GetSelectedExceptionDates/",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response)
        {
            callback(response);
        },
        error: function (err)
        {
            console.log(err);
        }
    });

};

var callback = function (dates)
{
    $.each(dates, function (i, date)
    {
        var splitDate = date.split('.');

    var day = splitDate[0];
    var month = splitDate[1];
    var year = splitDate[2];

    console.log(splitDate);
    console.log(new Date(year, (parseInt(month)-1).toString(), day));
});

};

getSelectedExceptionDates(callback);

そして、これは私が今サイトを調べることによって得たものです:

["12"、 "11"、 "2009"] General.js:1012009年11月12日木曜日00:00:00GMT + 0100(西ヨーロッパ標準時)

2つの異なるタイプがあり、両方のATMをログに記録します。

日付のリストをaddDisabledDatesメソッドに挿入する方法はありますか?

編集:私はそれを機能させました!

var callback = function (dates)
    {
        var date_ary = new Array();
        $.each(dates, function (i, date)
        {
            var splitDate = date.split('.');

            var day = splitDate[0];
            var month = splitDate[1];
            var year = splitDate[2];
            date_ary.push(new Date(month + "/" + day + "/" + year));
        });

        console.log(date_ary);

        $("#ExceptionDates").multiDatesPicker({
            minDate: 0,
            defaultDate: "+1w",
            firstDay: 1,
            dateFormat: "dd.mm.yy",
            addDisabledDates: date_ary,
            numberOfMonths: 1,
            onSelect: function ()
            {
                var dates = $("#ExceptionDates").multiDatesPicker('getDates');
                var html = '';
                $.each(dates, function (i, val)
                {
                    html += '<input type="text" name="Dates" value="' + val + '">';
                });

                $("#SelectedDates").html(html);
            }
        });
    };
    getSelectedExceptionDates(callback);

var getSelectedExceptionDates = function (callback)
{
    $.ajax({
        type: "POST",
        url: "/Route/GetSelectedExceptionDates/",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response)
        {
            callback(response);
        },
        error: function (err)
        {
            console.log(err);
        }
    });
};
4

1 に答える 1

1
$("#ExceptionDates").multiDatesPicker({

defaultDate: "+1w",
firstDay: 1,
dateFormat: "dd.mm.yy",
numberOfMonths: 1,
addDisabledDates: getSelectedExceptionDates(callback),
onSelect: function ()
  {
    var dates = $("#ExceptionDates").multiDatesPicker('getDates');
    var html = '';
    $.each(dates, function (i, val)
    {
        html += '<input type="text" name="Dates" value="' + val + '">';
    });

    $("#SelectedDates").html(html);
  }
 });

var getSelectedExceptionDates = function(callback)
{
    $.ajax({
        type: "POST",
        url: "/Route/GetSelectedExceptionDates/",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response)
        {
            return callback(response);
        },
        error: function (err)
        {
            console.log(err);
        }
    });

};
var callback = function (dates)
{
    var date_ary = new Array();
    $.each(dates, function (i, date)
    {
        var splitDate = date.split('.');

        var day = splitDate[0];
        var month = splitDate[1];
        var year = splitDate[2];
        date_ary.push(month + "/" + day + "/" + year );

    });
    return date_ary;
};

getSelectedExceptionDates(callback);
于 2012-09-07T07:08:16.297 に答える