0

我正在尝试使用 Jquery 自动完成功能,但得到以下信息:

Timestamp: 5/05/2013 11:45:10 PM
Error: TypeError: jQuery(...).autocomplete is not a function
Source File: xxx/test/wp-content/themes/maths-aust/js-files/checkout-suburb-lookup.js
Line: 31

HTML 的头部看起来不错:

<script type='text/javascript' src='xxx/test/wp-includes/js/jquery/jquery.js?ver=1.7.2'></script>
<script type="text/javascript" src="xxx/test/wp-content/themes/xxx/js-files/jquery-ui-1.10.3/js/jquery-ui-1.10.3.custom.min.js"></script>
<script type="text/javascript" src="xxx/test/wp-content/themes/xxx/js-files/checkout-suburb-lookup.js"></script>

脚本看起来像:

jQuery(document).ready(function() {    
  jQuery(function() {     
      jQuery( "#wpsc_checkout_form_22" ).autocomplete({
        source: function( request, response ) {
          jQuery.ajax({
            url: "http://ws.geonames.org/searchJSON",
            dataType: "jsonp",
            data: {
              featureClass: "P",
              style: "full",
              maxRows: 12,
              name_startsWith: request.term
            },
            success: function( data ) {
              response( jQuery.map( data.geonames, function( item ) {
                return {
                  label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
                  value: item.name
                }
              }));
            }
          });
        },
        minLength: 2,
        select: function( event, ui ) {
          //
        },
        open: function() {
          jQuery( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
        },
        close: function() {
          jQuery( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
        }
      });
    });
});

我很困惑为什么它找不到自动完成插件!

4

1 回答 1

0

我发现了这个问题。原来 Wordpress 已经包含了 UI!

于 2013-05-05T14:31:25.900 回答