setting dates to highlight booked dates in calendar of datepicker

心不动则不痛 提交于 2020-01-05 07:01:08

问题


i have this function that highlights the given dates and hide the others(not actually hide but undetectable).

var availableDates = ['1-12-2017','5-12-2017'];

  function availableFunction(date) {
      availday = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
      if (jQuery.inArray(availday, availableDates) > -1) {
          return [true,"eventday",""];
      } else {
          return [true,"ui-datepicker-unselectable ui-state-disabled ",""];
      }
  }

Now i am gettings dates from database by jquery and pass to the above function.

var t_date = jQuery('.date-<?php echo $post->ID?>').html();
var availableDates = [t_date];

code still working fine but i want to get multiple dates and highlights them. so i use this code.

var tttdates = document.getElementsByName("tttdate<?php echo $post->ID?>");
var vals=[];
for (var i=0, n=tttdates.length; i<n; i++) {
vals.push(tttdates[i].textContent);
}
alert(vals.join(","));

problem is that.

  var availableDates = [vals.join(",")];

i am not getting any dates highlighted. why is that?

来源:https://stackoverflow.com/questions/41485505/setting-dates-to-highlight-booked-dates-in-calendar-of-datepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!