【问题标题】:Error in localize DatePicker本地化 DatePicker 时出错
【发布时间】:2014-06-16 10:53:22
【问题描述】:

我正在尝试本地化 jquery datepicker,但由于我不是 jquery 专家,所以我收到一个错误,我不知道如何修复它。

错误

TypeError: 'undefined' is not an object (evaluating '$.ui.datepicker.regional')

这里是日期选择器的代码

calendar.js

$(function() {
    $( ".from" ).datepicker({
      defaultDate: "+1w",
      dateFormat: "dd/mm/yy",
      changeMonth: true,
      numberOfMonths: 1,
      onClose: function( selectedDate ) {
        $( ".to" ).datepicker( "option", "minDate", selectedDate );
      }
  });
    $( ".to" ).datepicker({
      defaultDate: "+1w",
      dateFormat: "dd/mm/yy",
      changeMonth: true,
      numberOfMonths: 1,
      onClose: function( selectedDate ) {
        $( ".from" ).datepicker( "option", "maxDate", selectedDate );
      }
    });
  });

和本地化

<script src="//jquery-ui.googlecode.com/svn-history/r3875/branches/labs/datepicker2/ui/i18n/jquery.ui.datepicker-it.js" ></script>

它们都在以下代码之后

<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
        <script src="//code.jquery.com/jquery-1.10.2.js"></script>
        <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

【问题讨论】:

    标签: jquery jquery-ui datepicker


    【解决方案1】:

    参考此链接 - Datepicker Localize

    Demo Fiddle

    $(function() {
        $( ".from" ).datepicker( $.datepicker.regional[ "it" ] );
        $( ".to" ).datepicker( $.datepicker.regional[ "it" ] );
    });
    

    使用下面的脚本标签作为参考。

     <script src="http://jquery-ui.googlecode.com/svn/tags/1.8.20/ui/i18n/jquery.ui.datepicker-it.js" ></script>
    
    • 您需要包含$.datepicker.regional[ "it" ] 才能应用本地化设置。

    Updated Demo

    【讨论】:

    • 是的......它就像一个魅力。太好了……还有一个问题。你知道如何调整日历的大小吗?
    猜你喜欢
    • 2013-02-21
    • 2010-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多