{% load i18n %}
<input type="text" name="{{ name }}" id="{{ html_id }}" value="{{ current_name }}" />
<script type="text/javascript">
jQuery(document).ready(function($){
        function formatItem_{{ html_id|cut:"-" }}(row) {
                return row[2]
        }
        function formatResult_{{ html_id|cut:"-" }}(row) {
                return row[1]
        }
        $('#{{ html_id }}').autocomplete('{{ lookup_url }}', {
                width: 320,
                formatItem: formatItem_{{ html_id|cut:"-" }},
                formatResult: formatResult_{{ html_id|cut:"-" }},
                dataType: "text",
                highlight: false
        })
        $('#{{ html_id }}').result(function(event, data, formatted) {
                $('#{{ html_id }}').val(data[1])
        })
});
</script>
