admin管理员组

文章数量:1395248

I have a date picker and i need to set to functions to run on BeforeShowDay.

I can't work out how to run both functions names unavailable and disabledays

/

Thanks in advance

Lee

I have a date picker and i need to set to functions to run on BeforeShowDay.

I can't work out how to run both functions names unavailable and disabledays

http://jsfiddle/rLnTQ/50/

Thanks in advance

Lee

Share Improve this question asked Jun 3, 2011 at 9:43 LeeLee 1,2804 gold badges18 silver badges37 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

How about bining them into one?

function disabledays(date) {
dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear();
if ($.inArray(dmy, unavailableDates) == 0) {
    return [false, "", "Unavailable"]
} else {
    var day = date.getDay();
    return [(day != 0 && day != 2)];
}

}

$('#txtDate').datepicker({ beforeShowDay: disabledays })

http://jsfiddle/rLnTQ/104/

Or you can put one within the other:

function unavailable(date) {
    dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear();
    if ($.inArray(dmy, unavailableDates) == 0) {
        return [false, "", "Unavailable"];
    } else {
        return disabledays(date);
    }
}

function disabledays(date) {
    var day = date.getDay();
    return [(day != 0 && day != 2)];


}

$('#txtDate').datepicker({
    beforeShowDay: unavailable
})

http://jsfiddle/rLnTQ/118/

本文标签: javascriptHow to set 2 functions with BeforeShowDay on jQuery DatepickerStack Overflow