我尝试并保持这一节奏。
页: 1 设置了供住宿网站使用的设备,以在日期/日期上进行检查。 使用<代码>在ShowDay前索取含有日期和比率的XML文件。 我开始这样做,是正确的。
当月变更时,我有<代码>MonthChange功能,可以重新索阅以下月/过去几个月的信息,但其中一个重要部分除外:
The Problem: If you quickly click through the months the XML data coming back in can t keep up, so dates incorrectly show as unavailable.
www.un.org/Depts/DGACM/index_spanish.htm 我需要以下一点:
。
- Once the data loads the calendar refreshes to show the correct availability
- The month forward button is disabled until the data has been loaded.
What I ve Tried
- Hiding the month change button at the start of the onMonthChange function then showing it at the end - this doesn t work.
- Using
async:false
in the get function - I feel this is the solution but I can t get it work as I can t find any clear documentation on where it s meant to go.
<><>Code>:
/* Date Picker */
var datepickerOptions = {
dateFormat: yy-mm-dd ,
};
var checkInOptions = {
showOtherMonths: false,
minDate: 0,
beforeShowDay: addPrice,
onSelect: openCheckout,
onChangeMonthYear: onMonthChange,
dateFormat: yy-mm-dd
};
j.getJSON("/availability.php?startDate="+year+"-0"+month+"-01&id="+j( #property_id ).text(),
{ format: "json" },
function(data) {
document.pricesData = data;
document.firstDate = ;
j( #calendar_check_in ).datepicker(checkInOptions);
/* Tip Tip */
j( .ui-datepicker-calendar td ).tipTip({ defaultPosition: "right" });
for (var key in document.pricesData) {
var obj = document.pricesData[key];
if(obj[ avail ] == 1 && document.firstDate == ){
document.firstDate = key;
}
}
d = new Date(document.firstDate.substr(5));
d.setMonth(d.getMonth()+1);
});
function addPrice(date) {
calDate = new Date(date);
dateString = date_ +calDate.getFullYear()+ - +( 0 +(calDate.getMonth()+1).toString()).substr(-2)+ - +( 0 +(calDate.getDate()).toString()).substr(-2);
if(document.pricesData[dateString] != undefined){
var priceString = document.pricesData[dateString][ price ];
if(document.pricesData[dateString][ avail ] == "1"){
valid = true;
} else {
valid = false;
}
}else{
var priceString = Price not available ;
valid = false;
}
return [valid, , priceString];
}
function onMonthChange(year, month, inst){
/* Date Picker */
month--;
j.getJSON("/availability.php?startDate="+year+"-0"+month+"-01&id="+j( #property_id ).text(),
{ format: "json" },
function(data) {
document.pricesData = data;
document.firstDate = ;
/* Tip Tip */
j( .ui-datepicker-calendar td ).tipTip({ defaultPosition: "right" });
for (var key in document.pricesData) {
var obj = document.pricesData[key];
if(obj[ avail ] == 1 && document.firstDate == ){
document.firstDate = key;
}
}
d = new Date(document.firstDate.substr(5));
d.setMonth(d.getMonth()+1);
});
}
由于需要时间阅读的人,希望有人会找到某种解决办法,因为此时此刻,它就是一个 show的bit子!
谢谢!