dongtan6543 2014-12-30 19:10
浏览 41
已采纳

自动完成不在PHP中给出自动完成未定义的错误

I am trying to add AutoComplete in my html

JQUERY AUTOCOMPLETE FILE LINK Here is how i have added it

<script src="<?php echo $site_root?>js/autocomplete/jquery.ui.autocomplete.autoSelect.js"></script>

Trying to access using

$("#username").autocomplete({
        source: <?php echo $username; ?>,   
        select: function(event, ui) 
        {
            var username = ui.item.label;
            window.location = 'submissionForm.php?username=' + username;
        }
    });

I am getting This error Cannot read property 'autocomplete' of undefined

What is wrong?

  • 写回答

2条回答 默认 最新

  • dtgv52982 2014-12-30 19:19
    关注

    If you open the autocomplete file you'll see something like:

    define([
        "jquery",
        "./core",
        "./widget",
        "./position",
        "./menu"
    ], factory );
    

    Those are the files you need additionally, in that order, on the page.

    <script src="path-to/jquery.min.js"></script>
    <script src="path-to/jquery-ui/ui/core.js"></script>
    <script src="path-to/jquery-ui/ui/widget.js"></script>
    <script src="path-to/jquery-ui/ui/position.js"></script>
    <script src="path-to/jquery-ui/ui/menu.js"></script>
    <script src="path-to/jquery-ui/ui/autocomplete.js"></script>
    

    If you don't care for any future additions regarding widgets, go get the complete minified version of jquery UI.

    Also CSS is important! To use custom builds, you propably don't want any aditional widget CSS since that will never be used.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制