JQuery UI – 无法在Modal Dialog中更改datepicker中的月/年

模式对话框中使用Datepicker ,不能在Firefox 19.0.2中使用Change Month / Year下拉列表,请参阅:

http://jsfiddle.net/469zV/2/

HTML

Date1:

脚本

 $( "#dialog-form" ).dialog({ modal: true }); $("#datepicker").datepicker({ changeMonth: true, changeYear: true }); 

搜索后很多可以找到有关此问题的一些信息,但没有关于解决方案:

http://bugs.jqueryui.com/ticket/8989#no1

任何想法如何解决这个…谢谢先进。

这可能不是您正在寻找的,但如果您删除文本输入,它将为您提供月份和年份选择。

工作实例

 $( "#dialog-form" ).dialog({ modal:true, height:340, width:340 }); $("#datepicker").datepicker({ changeMonth: true, changeYear: true, });     

选择日期后,您需要模糊文本框,以便重新触发焦点事件:

 $( "#dialog-form" ).dialog({ modal: true }); $("#datepicker").datepicker({ changeMonth: true, changeYear: true }).on('change',function(){ $(this).blur() }); 

这为我修好了:$(document).unbind(’focusin’);

这可能导致使用ui和bootstrap.js。 在body标签中添加的类modal-open具有overflow-y:hiiden 。 您需要省略该属性,并且datepicker年份更改将起作用

Jquery Ui Datepicker月/年下拉列表在最新的Firefox中弹出窗口不起作用

将此代码添加到您的JavaScript脚本或文件中。

  var enforceModalFocusFn = $.fn.modal.Constructor.prototype.enforceFocus; $.fn.modal.Constructor.prototype.enforceFocus = function() {}; $confModal.on('hidden', function() { $.fn.modal.Constructor.prototype.enforceFocus = enforceModalFocusFn; }); $confModal.modal({ backdrop : false });