Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Datepicker BeforeShowDay Second Parameter

jQuery's datepicker allows you to highlight dates using the BeforeShowDay callback.

Is it possible to pass a second parameter to the method?

$(selector).datepicker({beforeShowDay: selectedDay});   

function selectedDay(date) {

    // Do stuff

    return [true, 'class_name'];
}

As you can see, the parameter date is automatically passed to the selectedDay method, thus making me unsure as to how to pass a second parameter.

Cheers.

like image 281
Jarrod Avatar asked Jul 26 '12 00:07

Jarrod


1 Answers

function selectedDay(date, param ) {
     // Do stuff with param
     return [true, ''];
}

function doStuff(){
    var param = "param_to_pass";
    $(selector).datepicker({
        beforeShowDay: function (date){
            return selectedDay(date, param );
        }
    }); 
}  
like image 108
protasovams Avatar answered Sep 23 '22 22:09

protasovams