First time here? Check out the FAQ!
3

Implementing custom autocompleter

I wanted to know what autocompleter library you are using.

I'm trying to create another instance of this autocompleter that doesn't have space separated values(like how tags work), it simply needs to autocomplete only one value. I figured autocompleteMultiple=false would work as per this example.

{%- macro location_autocomplete_js(id = '#id_location') -%}
    var locationAc = new AutoCompleter({
            url: '{% url "get_location_list" %}',
            minChars: 3,
            useCache: true,
            maxCacheLength: 100,
            matchInside: false,
            autocompleteMultiple: false,
            delay: 10,
    });
    locationAc.decorate($("{{ id }}"));
{%- endmacro -%}

But I'm having no luck. Also it is possible to use this for json driven autocompletion. I wish to retrieve both names and unique ids from the server and use the unique id in the post request.

Cheers!

shano's avatar
1
shano
asked 2013-08-20 10:18:26 -0600, updated 2013-08-20 10:20:09 -0600
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1

These settings worked for me, make sure and bear in mind the stopCharRegex, any character here will cause the autocompleter to stop. The default setting for this stopped on spaces which was causing me most of my problems.

{%- macro location_autocomplete_js(id = '#id_location') -%}
    var locationAc = new AutoCompleter({
            url: '{% url "get_location_list" %}',
            minChars: 3,
            useCache: true,
            maxCacheLength: 100,
            matchInside: false,
            autocompleteMultiple: false,
            multipleSeparator: null,
            delay: 10,
            stopCharRegex: /\./
    });
    locationAc.decorate($("{{ id }}"));
{%- endmacro -%}
shano's avatar
1
shano
answered 2013-09-03 03:48:33 -0600
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments