-
-
Save rilwis/b7836dfac1300ade67b3da9555ef5bab to your computer and use it in GitHub Desktop.
How to Build a Hotel Booking Website Using Meta Box (P3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery( function($) { | |
setTimeout(function(){ | |
datepicker_reinstall(); | |
console.log(disable_dates); | |
}, 1000); | |
function datepicker_reinstall(){ | |
var dateFormat = "yy-mm-dd", | |
from = $( "#group_booking_check_in" ), | |
to = $( "#group_booking_check_out" ); | |
from.add(to).datepicker('destroy'); | |
from.datepicker({ | |
minDate: 0, | |
defaultDate: "+1w", | |
beforeShowDay: function(date){ | |
var string = jQuery.datepicker.formatDate('yy-mm-dd', date); | |
return [ disable_dates.indexOf(string) == -1 ] | |
} | |
}) | |
.on( "change", function() { | |
to.datepicker( "option", "minDate", getDate( this ) ); | |
}); | |
to.datepicker({ | |
defaultDate: "+1w", | |
beforeShowDay: function(date){ | |
var string = jQuery.datepicker.formatDate('yy-mm-dd', date); | |
return [ disable_dates.indexOf(string) == -1 ] | |
} | |
}) | |
.on( "change", function() { | |
from.datepicker( "option", "maxDate", getDate( this ) ); | |
}); | |
function getDate( element ) { | |
var date; | |
try { | |
date = $.datepicker.parseDate( dateFormat, element.value ); | |
} catch( error ) { | |
date = null; | |
} | |
return date; | |
} | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment