Javascript Date作为datepicker中的类
我正在寻找一种方法,使datepicker中的每个td都独一无二。我已经在每个突出显示的日期下设置了一个价格,但问题是每个日期的价格都是相同的Javascript Date作为datepicker中的类,javascript,jquery,datepicker,Javascript,Jquery,Datepicker,我正在寻找一种方法,使datepicker中的每个td都独一无二。我已经在每个突出显示的日期下设置了一个价格,但问题是每个日期的价格都是相同的 addCustomInformation : function(x) { window.bookingRequest.totalPrice = 0; window.bookingRequest.totalAccommodationOnlyPrice = 0; window.rateT
addCustomInformation : function(x) {
window.bookingRequest.totalPrice = 0;
window.bookingRequest.totalAccommodationOnlyPrice = 0;
window.rateTableRowIndex = 0;
var selectedTimeFrom = x;
var selectedTimeTo = x + 604800000;
while (selectedTimeFrom < selectedTimeTo) {
accommodations.buildRateRow(selectedTimeFrom, 1, 0, 3);
selectedTimeFrom += (86400000 * 7);
}
var price = accommodations.formatPrice(window.bookingRequest.totalAccommodationOnlyPrice);
var newprice = price.substring(3);
setTimeout(function() {
$(".ui-datepicker-calendar td").filter(function() {
var date = $(this).text();
return /\d/.test(date);
}).find("a").attr('data-custom', newprice); // Add custom data here
}, 0)
}
addCustomInformation:函数(x){
window.bookingRequest.totalPrice=0;
window.bookingRequest.TotalAccountationOnlyPrice=0;
window.rateTableRowIndex=0;
var selectedTimeFrom=x;
var selectedTimeTo=x+604800000;
while(selectedTimeFrom
此代码获取价格,但该价格被分配给“.ui datepicker calendar td”,而它不应分配给“.ui datepicker calendar td”。我希望它将价格添加到日历循环中的当前td。addCustomInformation函数在每个高亮显示的td上运行
我的想法是将日期添加为每个td的一个类,这样看起来就像这样
<td class="05-08-2016 dp-highlight"></td>
<td class="06-08-2016 dp-highlight"></td>
我想不出怎么做。如果可以,我可以将循环中的当前日期作为参数发送到函数,并将价格添加到正确的td
我不能在“beforeShowDay”中使用return,因为它用于返回高亮显示和禁用日期的不同类。在返回[true,‘dp highlight current date’]这样的当前返回中添加类也是不可能的,因为我无法在返回后运行addCustomInformation函数
函数中的x是用于计算价格的当前日期(以毫秒为单位)
任何其他解决办法也将受到欢迎
Michael在datepicker文件中,我设法在日历中的每个活动/可点击td中添加了一个id。我的自定义函数现在如下所示:
addCustomInformation : function(currentday, dateclass) {
window.bookingRequest.totalAccommodationOnlyPrice = 0;
window.rateTableRowIndex = 0;
var selectedTimeFrom = currentday;
var selectedTimeTo = currentday + 604800000 // the day one week from current day ;
while (selectedTimeFrom < selectedTimeTo) {
accommodations.buildRateRow(selectedTimeFrom, 1, 0, 3);
selectedTimeFrom += (86400000 * 7);
}
var price = accommodations.formatPrice(window.bookingRequest.totalAccommodationOnlyPrice);
var newprice = price.substring(4) // remove DKK from price;
setTimeout(function() {
$("." + dateclass).text('DKK ' + newprice) // add the price to the td;
},1000)
addCustomInformation:函数(currentday,dateclass){
window.bookingRequest.TotalAccountationOnlyPrice=0;
window.rateTableRowIndex=0;
var selectedTimeFrom=currentday;
var selectedTimeTo=currentday+604800000//从当前日期算起一周内的日期;
while(selectedTimeFrom
查看此页面并选择“Priser og bestilling”选项卡。然后按下fx“Billund-Sevilla”中的“Vælg datoer”按钮。在日历中,转到2月、3月、4月。有时价格显示DKK 0,而其他时间则显示正确的价格。如果刷新页面并重试,则会显示以前返回DKK 0的某些日期的价格。完全奇怪
关于这个问题有什么想法吗?是因为“NeWalk”变量在我把它添加到TD字段之前还没有计算出来吗?在这种情况下的任何解决方案?< /P>而不是使日期为类。考虑将其作为数据日期值=“05-082016”属性存储日期。嘿。谢谢你的回复。你知道怎么做吗?在代码中的什么地方?当你创建td时,添加一个数据属性data Date无法确定每个td是在哪里添加的。应该没那么难,但我不是javascript专家,在代码中找不到创建td的地方。你能添加一个标记和js代码吗这将有助于我理解和帮助你