Reputation: 25
I have loaded my Autocomplete combobox script from: http://jqueryui.com/demos/autocomplete/#combobox and it appears with my list.
Below it, I have a list that works just fine using:
Thanks to Jan Tielens Bloggings: http://weblogs.asp.net/jan/archive/2009/04/09/calling-the-sharepoint-web-services-with-jquery.aspx
How do I get the list to actually filter once something is selected? I assume its in the $(this).attr() but nothing seems to work.
Apologies in advance for the DAY1 Newbie question.
Thanks
Upvotes: 2
Views: 9335
Reputation: 5435
Use SPServices and use the select
option in autocomplete:
<link href="../css/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/jquery-ui.js"></script>
<script type="text/javascript" src="../js/jquery.SPServices-0.5.8.js"></script>
<script type="text/javascript">
$(document).ready (function() {
$().SPServices({
operation: "GetListItems",
async: true,
listName: "Resources",
CAMLViewFields: "<ViewFields>" +
"<FieldRef Name='Title' />" +
"<FieldRef Name='resource_link' />" +
"<FieldRef Name='image_url' />" +
"</ViewFields>",
completefunc: AttachAutoComplete
});
function AttachAutoComplete(xmlResponse) {
var domElementArray = $( "[nodeName=z:row]", xmlResponse.responseXML );
var dataMap = domElementArray.map(function() {
return {
value: $(this).attr('ows_Title'),
url: $(this).attr('ows_resource_link'),
image_url: $(this).attr('ows_image_url')
};
});
var data = dataMap.get();
$("input#inputAutoComplete").autocomplete({
source: data,
formatItem: function(row){
if(row){
return "<table><tr><td><img src=\"" + row.image_url + "\" border=\"0\" /></td><td>"+ row.value + " 55</td></tr></table>";
}
},
select: function(e, ui){
window.open(ui.item['url']);
}
});
}
</script>
Upvotes: 3
Reputation: 5979
You can fire an onkeyup even if you are using a standard input. It would look something like:
<input type="text" name="search" id="txtSearch" onkeyup="searchOpen()" />
Upvotes: 1