在Modal里面的JQuery datePicker changeYear

时间:2014-02-05 10:34:57

标签: jquery datepicker modal-dialog twitter-bootstrap-3

我在引导模式中使用DatePicker

$.datepicker.setDefaults($.datepicker.regional['it']);

$("#datepicker").datepicker( {showOn:"button",dateFormat: 'dd-mm-yy', 
     changeYear: true,
     yearRange:'1920:+0',
     buttonImageOnly: true, 
     buttonImage: '/icon-datepicker.png' 

}).on('change',function(){
     $(this).blur()
});

但是当我从组合框中选择一年时,模态消失了。为什么呢?

1 个答案:

答案 0 :(得分:1)

我在SO找到了解决方案。我重新发布代码:

// Since confModal is essentially a nested modal it's enforceFocus method
// must be no-op'd or the following error results 
// "Uncaught RangeError: Maximum call stack size exceeded"
// But then when the nested modal is hidden we reset modal.enforceFocus
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 });