jQuery onselect datetimepicker更改

时间:2012-05-30 16:18:05

标签: jquery jquery-plugins

使用http://trentrichardson.com/examples/timepicker/中的日期时间选择器,我必须更改用户点击特定日期时的最长时间。到目前为止,我的代码进行了一次AJAX调用,并获得当天每次点击的最长时间(每天不同的最长时间,并以数据库形式存在)。

现在我正在尝试刷新视图,以便显示更新的maxhour,但表单重置为“janaury 0”,当我关闭表单并单击它时,如果应用于所选的任何一天,则返回最后一个请求的maxhour。

要重置我已经使用了选项方法的表单,这不起作用,所以我有一个方法,在每个onselect事件上调用,它会破坏datetimepicker的旧属性并重新创建所有内容并分配属性。

我甚至尝试使用应该刷新视图的datetpicker的refresh方法。

初始分配

$("#startDate").datetimepicker({
    onSelect: function (date) {
        manipulate(date);
    },
    timeFormat: 'hh:mm:ss tt',
    hourMin: 8,
    hourMax: endHour,
    showSecond: false,
    stepMinute: 15,
    minuteGrid: 5,
    addSliderAccess: true,
    sliderAccessArgs: {
        touchonly: false
    },
    showOn: "button",
    buttonText: "Select a date to check out equipment(s).",
    buttonImage: "../images/calendar.gif",
    buttonImageOnly: true,
    defaultDate: "+0",
    changeMonth: false,
    numberOfMonths: 2,
    minDate: 0,
    maxDate: '+5w',
    beforeShowDay: unavailable,
    ampm: true
});

function manipulate(date) {
    var sendDate = date.toString();
    jQuery.ajax({
        url: "endtime.php",
        data: {
            day: sendDate
        },
        type: "POST",
        success: function (XML) {
            var answer = jQuery("data", XML).text();
            var time = answer.split(":");
            var timetemp = sendDate.split(" ");
            var timenew = timetemp[0] + " " + answer;
            //$("#startDate").datetimepicker.( "option" ,hourMax ,time[0]); this is one of the first approach
            $("#startDate").datetimepicker("destroy");
            //$("#startDate").datetimepicker("refresh");
            var DateOptions = {
                onSelect: function (date) {
                    manipulate(date);
                    //$("#startDate").datetimepicker("refresh");
                    //datepicker._gotoToday('#startDate');
                },
                timeFormat: 'hh:mm:ss tt',
                hourMin: 8,
                hourMax: time[0],
                showSecond: false,
                stepMinute: 15,
                minuteGrid: 5,
                addSliderAccess: true,
                sliderAccessArgs: {
                    touchonly: false
                },
                showOn: "button",
                buttonText: "Select a date to check out equipment(s).",
                buttonImage: "../images/calendar.gif",
                buttonImageOnly: true,
                defaultDate: "+0",
                changeMonth: false,
                numberOfMonths: 2,
                minDate: 0,
                maxDate: '+5w',
                beforeShowDay: unavailable,
                ampm: true,
                setDate: date
            }
            $("#startDate").datetimepicker(DateOptions);
        }
    })
}

任何帮助将不胜感激。

0 个答案:

没有答案