Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: Object [object Object] has no method 'autocomplete'

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.

My code:

<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" />
like image 539
Lehan Coetzee Avatar asked Nov 05 '12 09:11

Lehan Coetzee


2 Answers

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.

like image 63
Lehan Coetzee Avatar answered Oct 05 '22 09:10

Lehan Coetzee


You can either remove the header or change the position of the header including.

Place your Header at the top of the file.

like image 21
Manwal Avatar answered Oct 05 '22 09:10

Manwal