2011-03-16 51 views
0

可能重複:
Can the jQuery UI Datepicker be made to disable Saturdays and Sundays (and holidays)?啓用/禁用特定日期

我會得到一組從數據庫日期。我必須在jQuery日曆中僅啓用這些日期。我該怎麼做 ?

+1

嗨,我們都願意幫助你,但你必須通過嘗試一些代碼來幫助自己第一,在這裏張貼,也許接受一些回答您以前的問題,而你在它:) – corroded 2011-03-16 04:30:50

+0

你會問關於你使用什麼日曆? – 2011-03-16 04:42:19

回答

0

您可以使用此jQuery插件,這使得使用jQuery UI的日期選擇器的

http://balupton.com/sandbox/jquery-sparkle/demo/#eventcalendar

就查詢數據庫,並在此格式返回一個JSON對象

{ 
    "entries": [ 
     { 
      "id": 1, 
      "title": "My First Entry", 
      "start": "2010-07-14 11:11:00", 
      "finish": "2010-07-14 14:23:18", 
      "user": { 
       "name": "Joe" 
      } 
     }, 
     { 
      "id": 2, 
      "title": "My Second Entry", 
      "start": "2010-07-14 11:11:00", 
      "finish": "2010-07-15 14:23:18", 
      "user": { 
       "name": "Joe" 
      } 
     } 
    ] 
} 

然後只需添加它作爲插件的一個選項:

$eventCal.EventCalendar({ 
     // Ajax Variables 
     /** The JSON variable that will be return on the AJAX request which will contain our entries */ 
     ajaxEntriesVariable: 'entries', 
     /** The AJAX url to request for our entries */ 
     ajaxEntriesUrl: './eventcalendar.json' 
});