2012-04-17 38 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

相關問題