I am trying to use the jquery autocomplete plugin but am having trouble getting it to attach to my textarea #message or #messageid, (two different ones). It works when I set the function attach() to the onClick events of either element but if I execute it normally, or use $(document).ready(attach()) it doesn’t seem to do anything.
This is the culled code of a page I made to try and debug it that retains the issue (the real page is fairly complex, split into a few files)
Thanks!
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(attach())
function attach(){
$("#messageid").autocomplete({
source: function(request, response){
$.post("utilities/atuser.php", {data: request}, function(data){
alert(data);
});
},
appendTo: "#content"
});
}
</script>
</head>
<body>
<form action="utilities/s_shoutout.php" method="post" id="sideshoutout" class="frmshoutout">
<textarea name="message" cols="25" id="messageid" onclick=";"></textarea>
<br /><br />
<input type="submit" />
Try the Following one:
Hope this one helps you 🙂
EDIT: Added missing “);”