相关疑难解决方法(0)

在jQuery UI datepicker中仅选择特定日期(日期列表来自AJAX)

在这里,我发送电影ID并获取可用日期,我想将其设置为日历.但它不起作用,它禁用所有日期.从PHP返回日期字符串.日期字符串正确,但日历不起作用.请帮忙.

日期字符串示例

"28-02-2012","29-02-2012","01-03-2012","02-03-2012","03-03-2012","04-03-2012","05-03-2012","06-03-2012","07-03-2012","08-03-2012","09-03-2012","28-02-2012","29-02-2012","01-03-2012","02-03-2012","03-03-2012","04-03-2012","05-03-2012","06-03-2012","07-03-2012","08-03-2012","09-03-2012"
Run Code Online (Sandbox Code Playgroud)

jQuery.post('index.php', {
  'option': 'com_movie',
  'controller': 'reservation',
  'task': 'datelist',
  'format': 'raw',
  'mid': movieid
}, function(result) {
  var onlydates = result.split(',');
  jQuery("#datepicker").datepicker({
    dateFormat: 'yy-mm-dd',
    showOn: "button",
    buttonImage: "<?php echo IMAGES_LINK.'calendar.png';?>",
    buttonImageOnly: true,
    beforeShowDay: function(date) {
      dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear();
      console.log(dmy + ' : ' + (jQuery.inArray(dmy, onlydates)));
      if (jQuery.inArray(dmy, onlydates) != -1) {
        return [true, "", "Available"];
      } else {
        return [false, "", "unAvailable"];
      }
    }
  });
  return;
});
Run Code Online (Sandbox Code Playgroud)

ajax jquery jquery-ui date jquery-ui-datepicker

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

ajax ×1

date ×1

jquery ×1

jquery-ui ×1

jquery-ui-datepicker ×1