2016-09-20 115 views
1

我想知道是否有一種方法,總是在datepicker今天突出顯示,即使使用beforeshowday和beforeshowday今天設置爲false。今天始終突出顯示datepicker

例如:

beforeShowDay: function(date) { 
    // make days selectable or not 
    if($.inArray($.datepicker.formatDate('yy-mm-dd', date), non_project_dates) > -1) { 
     return [false,'','']; 
    } 
    else { 
     return [true,'','']; 
    } 
}, 

如果今天設法下降不可選天之下,樣式將被覆蓋。我如何保持風格,同時仍然不可選?

謝謝。

編輯:

我能檢查的今天,但建議樣式僅將更改日細胞的輪廓。我試圖添加爲今天的單元格找到的多個樣式類,但灰色的樣式似乎仍然覆蓋今天的高亮樣式。

beforeShowDay: function(date) { 
    // make days selectable or not 
    if ($.datepicker.formatDate('yy-mm-dd', calendar_start_date) == $.datepicker.formatDate('yy-mm-dd', date)) { 
     console.log("Matched today."); 
     return [false,'ui-state-highlight','']; 
    } 
    else if($.inArray($.datepicker.formatDate('yy-mm-dd', date), non_project_dates) > -1) { 
     return [false,'','']; 
    } 
    else { 
     return [true,'','']; 
    } 
} 
+1

對不起,這是jQuery的(JS)。我已將它添加到標籤。 – user3442612

回答

1

不是最終答案,但也許這可以幫助你。今天是這個類

ui-state-highlight 

在負責這個jQueryUI的代碼高亮是

tbody += "<td class='" + 
          ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends 
          (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months 
          ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key 
          (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ? 
          // or defaultDate is current printedDate and defaultDate is selectedDate 
          " " + this._dayOverClass : "") + // highlight selected day 
          (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days 
          (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates 
          (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day 
          (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different) 
          ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title 
          (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions 
          (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months 
          (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" + 
          (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") + 
          (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day 
          (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months 
          "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date 
相關問題