[英]Show “price” text on date using JQuery-UI Datepicker?
I Hope someone can help me... 我希望有一个人可以帮助我...
I use JQuery-UI Datepicker to show my booking calendar. 我使用JQuery-UI Datepicker显示预订日历。 I already success for show datepicker with different date colour. 我已经成功地用不同的日期颜色显示日期选择器。 But i need to show my booking price on every date in jquery-ui datepicker. 但是我需要在jquery-ui datepicker中显示每个日期的预订价格。 How can i do it? 我该怎么做? is there any example? 有什么例子吗? This is my code : 这是我的代码:
function checkAvailability(mydate){
if (jResult==null)
{
return [true,"ui-state-notbooked"];
}
else
{
var $return=true;
var $returnclass ="ui-state-notbooked";
$checkdate = $.datepicker.formatDate('yy-mm-dd', mydate);
$.each(jResult, function(key, val){
var date1 = $checkdate.split("-");
var date2 = key.split("-");
if(date1[1]==date2[1] && date1[2]==date2[2])
{
switch (val)
{
case "red":
$returnclass= "preBookedRed_class";
break;
case "blue":
$returnclass= "preBookedBlue_class";
break;
case "yellow":
$returnclass= "preBookedYellow_class";
break;
default:
$returnclass= "preBooked_class";
}
}
});
return [$return,$returnclass];
}
}
This function call at beforeShowDay in DatePicker. 此函数在DatePicker中的beforeShowDay调用。 This code just for show different colour in datepicker. 此代码仅用于在datepicker中显示不同的颜色。
Not knowing which version you are using, I am basing this on the github version https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js line 1560 in the _generateHTML() function: 您使用的,不知道哪一个版本,我在GitHub的版本基础这个https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js线1560在_generateHTML()功能:
'" href="#">' + printDate.getDate() + '</a>')) + '</td>';
adding in your pricing should be easy, just stick in some extra markup: 添加价格应该很容易,只需加上一些额外的标记即可:
'" href="#">' + printDate.getDate() + '</a>')) + '<span class="booking-price">$0.00</span></td>';
I would recommend extending the datepicker and creating your own so that updates do not interfere with customizations, a good article can be found here: http://bililite.com/blog/extending-jquery-ui-widgets/ 我建议您扩展日期选择器并创建自己的日期选择器,以便更新不会干扰自定义,可以在此处找到不错的文章: http : //bililite.com/blog/extending-jquery-ui-widgets/
Good luck! 祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.