一部の日付に特定の価格を表示するには、JqueryUIのdatepickerで一部の日付にカスタムテキストを表示する必要があります。私のアイデアは、beforeShowDayを使用してそのような日付のタイトルに特定の価格を付け、次にbeforeShowで各tdをチェックアウトし、タイトルのテキストをセルに配置することでした。例:
var m, d, y, checkDate, specificPrice = '';
var specificPrices = {"2013-3-8":"300 EUR", "2013-2-26":"263 EUR"}
$('#my-datepicker').datepicker({
beforeShowDay: function checkAvailable(date) {
m = date.getMonth();
d = date.getDate();
y = date.getFullYear();
checkDate = y + '-' + (m+1) + '-' + d;
if(specificPrices[checkDate]){
specificPrice = specificPrices[checkDate];
}else{
specificPrice = '';
}
return [true, "", specificPrice];
},
beforeShow: function(elem, inst){
$('table.ui-datepicker-calendar tbody td', inst.dpDiv).each(function(){
var calendarPrice = $(this).attr('title');
if(calendarPrice != undefined){
$(this).find('a').append('<span class="calendar-price">' + calendarPrice + '<span>');
}
});
}
});
これにより、最初のカレンダーレンダリング(月/年が変更される前)およびインラインカレンダーのみの価格がレンダリングされます。
インラインではないカレンダーや月/年の変更にも価格を表示する必要があります。
他のいくつかのバリアントを試し、onChangeMonthYearを使用しようとしましたが、これまでのところ成功していません。
ご清聴ありがとうございました、あなたのアイデアは大歓迎です。