2011-05-04 71 views
1
  1. 我有一個按鈕,當我點擊按鈕時,我想相應地重裝DatePicker並從我的click事件中啓動datePicker的beforeShowDay事件。
    我該怎麼做?
  2. 如何將DatePicker日期設置爲ListDate [0]日期?如何調用OnChange DatePicker事件

    var ListDate = new Array(); 
    var ID; 
        $(function() 
        { 
           $("#myDateDiv").datepicker({ 
         showOtherMonths: true, 
         selectOtherMonths: true, 
         dateFormat: "yy/mm/dd", 
         onSelect: function (dateText, inst) 
         {      
          //    
         }, 
         onChangeMonthYear: function(year, month, inst) 
         { 
    
        }, 
         beforeShowDay: function(dateToShow) 
         { 
          testFunction(dateToShow, ID); 
          ListDate = getListdateFuction(); 
          ///How to set the datePicker date to ListDate[0] 
         }); 
           }); 
        }); 
    

    $("test").click(function(){ 
    How to call datePicker berforeShowDay or onChange function ??? 
    }); 
    

回答

1
如果你想設置的日期使用的setDate

$("test").click(function(){ 
    $('#dateselector').datepicker("setDate", new Date(2011,5,12)); 
}); 

當您更改月份看到WORKING DEMO

+0

設置的onChangeMonthYear將被觸發日期很簡單,但我寧願啓動ONC hnage功能。如何在上面的代碼中設置日期? – learning 2011-05-04 12:34:19

+0

@ user281180請參閱編輯 – mcgrailm 2011-05-04 13:02:06

+0

謝謝,我想在beforeShowDay事件中設置datePicker ... – learning 2011-05-04 13:09:15