Jquery 不同屏幕分辨率下的引导日期时间选择器截止
我正在开发一个mvc应用程序,需要使用bootstrap日期时间选择器。它工作正常,但分辨率为800*1280和768*1024 页面的视图为Jquery 不同屏幕分辨率下的引导日期时间选择器截止,jquery,twitter-bootstrap,asp.net-mvc-4,Jquery,Twitter Bootstrap,Asp.net Mvc 4,我正在开发一个mvc应用程序,需要使用bootstrap日期时间选择器。它工作正常,但分辨率为800*1280和768*1024 页面的视图为 <div class="col-sm-3"> <div class="col-sm-12">date of birth</div> <div class="col-sm-12"> <div class='input-g
<div class="col-sm-3">
<div class="col-sm-12">date of birth</div>
<div class="col-sm-12">
<div class='input-group date'>
@Html.TextBoxFor(c => c.BIRTHDATE, "{0:MM/dd/yyyy}", new { @class = "date-picker form-control" })
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
我们正在使用datepicker.css和jquery-1.11.0.js、bootstrap.css作为这个日期选择器。
请提供解决此问题的方法。经过大量研究,我最终选择了jquery使其正常工作。请查看下面的代码 首先,我们将只处理窗口的调整大小事件,如下所示:
$(window).on("resize",function () {
ApplyDatepicker();
});
然后,我们将根据分辨率处理日期选择器方向:
function ApplyDatepicker()
{
$('.date-picker').datepicker('hide');
$('.date-picker').blur();
if ($(window).width() >= 760) {
$(".date-picker").datepicker({
orientation: "auto right"
});
}
else
{
$(".date-picker").datepicker({
orientation: "auto left"
});
}
$('.date-picker').datepicker('update');
$('.date-picker').on('changeDate', function (ev) {
$(this).datepicker('hide');
});}
应用此日期选择器后,现在将自动调整其位置
function ApplyDatepicker()
{
$('.date-picker').datepicker('hide');
$('.date-picker').blur();
if ($(window).width() >= 760) {
$(".date-picker").datepicker({
orientation: "auto right"
});
}
else
{
$(".date-picker").datepicker({
orientation: "auto left"
});
}
$('.date-picker').datepicker('update');
$('.date-picker').on('changeDate', function (ev) {
$(this).datepicker('hide');
});}