滚动模态时,bootstrap-datepicker不会滚动 [英] bootstrap-datepicker does not scroll when scrolling the modal
本文介绍了滚动模态时,bootstrap-datepicker不会滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用
滚动模态时是否有任何解决方案使其滚动?
解决方案
有选项 datepicker('place')
来更新位置。我已更新 jsfiddle
var datePicker = $(。calendar)。datepicker({});
var t;
$(document).on(
'DOMMouseScroll mousewheel scroll',
'#myModal',
function(){
window.clearTimeout(t);
t = window.setTimeout(function(){
$('。calendar')。datepicker('place')
},100);
}
);
I am using bootstrap-datepicker and would like to show the date-picker on the modal of bootstrap 2. The problem I got is the date-picker is not scrolling accordingly when scrolling the modal, it is still remained.
The code:
<button class="btn btn-primary" data-toggle="modal" data-target="#myModal">Launch Modal</button>
<div id="myModal" class="modal hide fade" style="height: 400px; overflow: scroll">
<div style="height:300px"></div>
<div>Choose Date:
<input class="calendar" />
</div>
<div style="height:300px"></div>
</div>
and javascript:
var datePicker = $(".calendar").datepicker({});
The jsfiddler: http://jsfiddle.net/csrA5/
Is there any solution to make it scroll when scrolling the modal?
解决方案
There is option datepicker('place')
to update position . I have updated jsfiddle
var datePicker = $(".calendar").datepicker({});
var t ;
$( document ).on(
'DOMMouseScroll mousewheel scroll',
'#myModal',
function(){
window.clearTimeout( t );
t = window.setTimeout( function(){
$('.calendar').datepicker('place')
}, 100 );
}
);
这篇关于滚动模态时,bootstrap-datepicker不会滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文