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" />
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.
You can either remove the header or change the position of the header including.
Place your Header at the top of the file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With