can’t bind a function to `beforeShowDay` from jQuery UI
-
Hi,
I am new to CMB2 trying to create a plugin for event calendar and In a form I want to bind date picker to a function that will check the already available event dates and dont let user to click them when booking for new event.A function here https://jsfiddle.net/yXMKC/2714/ is in working condition just for to use in beforeShowDay method of jQuery Ui datepicker and failing to do that
below is my code for the field
$cmb->add_field( array(
‘name’ => __( ‘Date of Booking’, ‘wds-post-submit’ ),
‘id’ => $prefix . ‘date_of_booking’,
‘type’ => ‘text_date’,
‘default’ => __( ”, ‘wds-post-submit’ ),
‘attributes’ => array(
// CMB2 checks for datepicker override data here:
‘placeholder’ => ‘Date of Booking’,
‘required’ => ‘required’,
‘readonly’ => ‘readonly’,
‘data-datepicker’ => json_encode( array(
‘beforeShowDay’ => check_available,
‘yearRange’ => ‘2017:2018’,
‘minDate’ => $todays_date,
) ),
),
‘date_format’ => ‘d-m-Y’,
‘before_row’ => ‘<br><p>BOOKING INFORMATION</p>’,) );
I get an error
Uncaught TypeError: q.apply is not a function
I tried following
function check_available(datep) {
availableDates = [“9-5-2017”, “14-5-2017”, “15-5-2017”];dmy = datep.getDate() + “-” + (datep.getMonth()+1) + “-” + datep.getFullYear();
// console.log(dmy+’ : ‘+($.inArray(dmy, availableDates)));
if ($.inArray(dmy, availableDates) != -1) {
return [false, ” “,”Not Available”];
} else {
return [true,” “,”Available”];
}
}also I tried binding
function check_available(datep) {
return [true,” “,”Available”];
}
no success!Can you please guide me on this?
Thanks & Regards,
Anil Durugkar
- The topic ‘can’t bind a function to `beforeShowDay` from jQuery UI’ is closed to new replies.