未捕获的TypeError:对象[object Object]没有方法'autocomplete' [英] Uncaught TypeError: Object [object Object] has no method 'autocomplete'

查看:96
本文介绍了未捕获的TypeError:对象[object Object]没有方法'autocomplete'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不断收到错误:未捕获的TypeError:对象[object Object]没有方法'autocomplete'.直到几天前,它都运行良好,而且我似乎找不到问题.似乎正在加载jquery-ui,所以我不明白为什么该方法无法正常工作.

I keep on getting the error: Uncaught TypeError: Object [object Object] has no method 'autocomplete'. It was working fine, until a few days ago and I can't seem to find the problem. It seems like jquery-ui is being loaded so I don't understand why the method isn't working.

我的代码:

<link href="css/redmond/jquery-ui-1.9.1.custom.css" rel="stylesheet">
<script src="js/jquery-1.8.2.js"></script>
<script src="js/jquery-ui-1.9.1.custom.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(function() {
    $(function() {
        $( "#tags" ).autocomplete({
            source: "autocomplete_members.php?term="+ $("#tags").val()
        }).data( "autocomplete" )._renderItem = function( ul, item ) {
        var inner_html = '<a href="#" onclick="setId(\'' + item.id + '\');"><img src="' + item.img + '" width="40px" height="40px" style="vertical-align: middle;padding-bottom: 2px;padding-right: 4px;" />' + item.value + '</a>';
        return $( "<li></li>" )
            .data( "item.autocomplete", item )
            .append(inner_html)
            .appendTo( ul );
        };
    });
});

function setId(val){
    document.getElementById("member-id-text").value = val;
};
});
</script>

-------------------------------------------HTML-----------------------------------

<input id="tags" size="35"/>
<input type="hidden" name="member-id-text" id="member-id-text" />

推荐答案

我发现了问题.我在使用JQuery但未使用JQueryUI的页面上包含一个标题,由于某种原因,这些标题发生冲突(仍不能完全确定为什么),但在标题中包含JQueryUI脚本解决了该问题.谢谢大家的帮助.

I found the problem. I was including a header on the page that used JQuery but not JQueryUI, for some reason these to clashed (still not entirely sure why) including the JQueryUI script in the header fixed the problem. Thanks for everyone's help.

这篇关于未捕获的TypeError:对象[object Object]没有方法'autocomplete'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆