2012-05-29 41 views
1

我需要從我自己的按鈕上撥打$.datepicker._gotoToday;

我以這種方式添加自定義按鈕:

beforeShow: function (input) { 
     setTimeout(function() { 
      var bodyPane = $(input).datepicker("widget"); 

      $("<button>", { 
       click: function() { 
       // call $.datepicker._gotoToday; 
       } 
      }).attr("class", "btnToday").text("test").appendTo(bodyPane); 
     }, 1); 
    } 

有沒有辦法來調用函數或「克隆」了嗎?

回答

0

你應該能夠只是設置日期在點擊功能選擇器:

$(input).datepicker("setDate", new Date()); 
0

試試這個:

$(function(){ 
    $("#id_input").datepicker({ 
    showButtonPanel: true, 
    changeMonth: true, 
    changeYear: true 
    }); 
}); 
$('#id_input').click(function(){ 
    $('.ui-datepicker-current').trigger('click'); 
    $('.ui-datepicker-buttonpane').hide(); 
}); 

它確定爲我)