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!

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
shano's avatar
1
shano
asked 11 years ago, updated 11 years ago

Comments

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 -%}

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
shano's avatar
1
shano
answered 11 years ago
link

Comments

see more comments