我只是将元素附加到面板包装器并调用.button()?
解决方法
如果要在滚动月份期间保持“清除”按钮,请使用onChangeMonthYear:。
一个例子:
- $( "#datepicker" ).datepicker({
- showButtonPanel: true,beforeShow: function( input ) {
- setTimeout(function() {
- var buttonPane = $( input )
- .datepicker( "widget" )
- .find( ".ui-datepicker-buttonpane" );
- $( "<button>",{
- text: "Clear",click: function() {
- //Code to clear your date field (text Box,read only field etc.) I had to remove the line below and add custom code here
- $.datepicker._clearDate( input );
- }
- }).appendTo( buttonPane ).addClass("ui-datepicker-clear ui-state-default ui-priority-primary ui-corner-all");
- },1 );
- },onChangeMonthYear: function( year,month,instance ) {
- setTimeout(function() {
- var buttonPane = $( instance )
- .datepicker( "widget" )
- .find( ".ui-datepicker-buttonpane" );
- $( "<button>",read only field etc.) I had to remove the line below and add custom code here
- $.datepicker._clearDate( instance.input );
- }
- }).appendTo( buttonPane ).addClass("ui-datepicker-clear ui-state-default ui-priority-primary ui-corner-all");
- },1 );
- }
- });