Ask Your Question
3

Implementing custom autocompleter

asked 2013-08-20 10:18:26 -0600

shano gravatar image

updated 2013-08-20 10:20:09 -0600

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!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-09-03 03:48:33 -0600

shano gravatar image

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 -%}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-08-20 10:18:26 -0600

Seen: 137 times

Last updated: Sep 03 '13