javascript – 选择日期后避免重新打开datepicker

前端之家收集整理的这篇文章主要介绍了javascript – 选择日期后避免重新打开datepicker前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
只有在这个代码的IE中 @H_403_2@$('#datepicker').datepicker({ onSelect : function(x,u){ $(this).focus(); } });

当我选择一个日期时,datepicker会重新打开,因为我添加了$(this).focus();在onSelect.我该如何解决这个问题? (Example)

我使用jquery 1.8.2和jquery-ui 1.9

解决方法

这是我可以得到的最好的解决方法

(灵感来自this link)

jsFiddle

@H_403_2@$('#datepicker').datepicker({ /* fix buggy IE focus functionality */ fixFocusIE: false,onSelect: function(dateText,inst) { this.fixFocusIE = true; $(this).change().focus(); },onClose: function(dateText,inst) { this.fixFocusIE = true; this.focus(); },beforeShow: function(input,inst) { var result = $.browser.msie ? !this.fixFocusIE : true; this.fixFocusIE = false; return result; } }).click(function(){$(this).focus()});

请注意,您在问题中建议,im使用jquery-UI 1.9.0.在您的示例中,您使用的是jquery-ui 1.8.15,它已知在某些事件(例如IE上的ShowShow()之前)是错误的.

猜你在找的JavaScript相关文章