Has anyone had any experience with using jTemplates to display autocomplete results.
I have the following
$("#address-search").autocomplete({
source: "/Address/SearchAddress",
minLength: 2,
delay: 400,
focus: function (event, ui) {
$('#address-search').val(ui.item.name);
return false;
},
parse: function(data) {
$("#autocomplete-results").setTemplate($("#templateHolder").html());
$("#autocomplete-results").processTemplate(data);
},
select: function (event, ui) {
$('#address-search').val(ui.item.name);
$('#search-address-id').val(ui.item.id);
$('#search-description').html(ui.item.address);
});
and the simple jtemplate holder:
<script type="text/html" id="templateHolder">
<ul class="autocomplete">
{#foreach $T as data}
<li>{$T.name}</li>
{#/for}
</ul>
</script>
Above i'm using 'Parse' to format results, I've also tried the autocomplete result method but not having any luck so far. The only success I've had is by using the private method ._renderItem and formatting the data that way but we want to render the output using the jTemplate.
Any advice appreciated.