2012-08-08 42 views
0

函數beforeShow不適用於內聯日期選擇器。如何在面板上添加其他按鈕?如何在jQueryUi的內聯日期選擇器上添加按鈕

beforeShow: function(input) { 
       setTimeout(function() { 
       var buttonPane = $(input).datepicker("widget").find(".ui-datepicker-buttonpane"); 
       var btn = $('<button class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" type="button">Clear</button>'); 
       btn.unbind("click").bind("click", function() { 
        $.datepicker._clearDate(input); 
       }); 

       btn.appendTo(buttonPane); 

       }, 1); 
      } , 

感謝您的任何答案。

回答

2

你可以在這裏找到一個例子。我希望對你有用的情況下

http://csharptechies.blogspot.ca/2010/12/adding-custom-buttons-to-jquery.html

您也可以做到這一點....

在你日期選擇器聲明:

 jQuery("#to").datepicker({ 
       dateFormat: 'yy-mm-dd', 
       inline: true, 
       changeMonth: true, 
       showButtonPanel: true,    
       numberOfMonths: 2, 
       minDate: -20, 

          beforeShow: buttonClear, 



/* Function button Clear */ 
    function buttonClear(input) { 
      setTimeout(function() { 
      var buttonPane = jQuery(input) 
       .datepicker("widget") 
       .find(".ui-datepicker-buttonpane"); 

      jQuery("<button>", { 
       text: "Clear", 
       class: "ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all", 
       click: function() { 
        jQuery.datepicker._clearDate(input); 



       } 
      }).appendTo(buttonPane); 
      }, 1); 
    } 

Regards

相關問題