2012-04-17 30 views
1

我试图用jquery-ui-1.8.17显示和设置12个月日期选择日历。 在Styling the jQueryUI DatePicker的帮助下,日历最初显示正常,即它显示了3行中的完整年份,每行包含4个月。 但是,当我点击日历中的一天时,显示器跳转到包含12个月的1行! 任何人看到这种奇怪的行为也有或有解决办法?jQueryUI DatePicker在日期点击12个月查看“跳转”

注意:在我的代码中,我包含了jquery-ui-1.8.17.custom.css。这是与http://jqueryui.com/themeroller生成的文件。请参阅css文件中的链接。

下面是完整的代码

<!DOCTYPE html> 
<html> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">   
    <link rel="stylesheet" type="text/css" media="screen" href="http://www.j2u.nl/jquery-ui-1.8.17.custom.css" /> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> 
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/jquery-ui.min.js" type="text/javascript"></script> 
    <script src="http://jquery-ui.googlecode.com/svn-history/r3982/trunk/ui/i18n/jquery.ui.datepicker-nl.js" type="text/javascript"></script> 

    <script> 
    $(document).ready(function(){ 
     $(".datepicker").datepicker ({ 
     dateFormat: 'dd-MM-yy', 
     firstDay: 1, // rows starts on Monday 
     minDate: new Date(), 
     maxDate: '+1Y', 
     numberOfMonths: 12 
    }); 
    $(".ui-datepicker-inline").width("850px"); 
    $(".ui-widget").css("font-size","0.9em"); 
    }); 
    </script>   
</head> 
<body> 
    <p><div class="datepicker"></div></p> 
</body> 

</html> 
+0

请张贴一个例子或你的代码的其余部分,包括CSS。我抛出了你在jsFiddle上发布的内容并获得了一个长长的几个月。 – j08691 2012-04-17 20:33:31

+0

现在添加完整的代码!另外作为一个小提琴:http://jsfiddle.net/r7pEe/ – rwijngaa 2012-04-18 17:01:46

回答

5

哇,张贴问题了jQuery UI的错误列表,5分钟后,有人回答了这个问题。 基本上NUMBEROFMONTHS:[3,4],并添加样式做的伎俩:

<style>.ui-widget { font-size: 62.5% }</style> 
<script> 
$(document).ready(function(){ 
    $(".datepicker").datepicker ({ 
    dateFormat: 'dd-MM-yy', 
    firstDay: 1, // rows starts on Monday 
    minDate: new Date(), 
    maxDate: '+1Y', 
    numberOfMonths: [3,4] 
}); 
}); 

+0

(你应该把它标记为答案,如果是的话)。) – 2012-07-26 17:30:51

+0

实际上它没有帮助。我有2个月在2列,我设置NumberOfMonths:[2,1],然后NumberOfMonths:[2,1]他们都没有工作 – 2017-01-18 14:14:48

相关问题