31

TypeError: $(...).autocomplete is not a functionモジュール内で次のコードを使用すると、エラーが発生しDrupalます。

jQuery(document).ready(function($) {
        $("#search_text").autocomplete({
            source:results,
            minLength:2,
            position: { offset:'-30 0' },  
            select: function(event, ui ) { 
                    goTo(ui.item.value);
                    return false;
            }        
    }); 
});

jQueryは間違いなくロードされており、$に別の変数を使用してみました - 他に何が問題なのですか?

(編集) オートコンプリートに対する Drupal 固有の回答:

drupal_add_library('system', 'ui.autocomplete');
4

6 に答える 6

79

あなたはjquery uiライブラリを逃しました。Jquery UI の CDN を使用するか、ローカルで使用する場合はJquery Uiからファイルをダウンロードします。

<link href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" rel="Stylesheet">
<script src="YourJquery source path"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js" ></script>
于 2013-04-30T13:07:48.727 に答える
4

簡単な解決策: オートコンプリート ライブラリを含める場合、シーケンスは非常に重要です。

<link href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" rel="Stylesheet">
<script src='https://cdn.rawgit.com/pguso/jquery-plugin-circliful/master/js/jquery.circliful.min.js'></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js" ></script>
于 2017-03-08T06:55:30.767 に答える
3

In my exprience I added two Jquery libraries in my file.The versions were jquery 1.11.1 and 2.1.Suddenly I took out 2.1 Jquery from my code. Then ran it and was working for me well. After trying out the first answer. please check out your file like I said above.

于 2016-11-10T12:46:10.733 に答える