Search code examples
jqueryjquery-uiautocompletebootstrap-tokenfield

tokenfield with jquery ui autocomplete


I am using Bootstrap tokenfield with jQuery UI autocomplete. But the list is not displaying any thing except blank fields.

This is my code:

$('#country').tokenfield({
   autocomplete: {
      source: "/country", minLength: 1
   },
   showAutocompleteOnFocus: true
});

Source is returning appropriate data but the autocomplete suggestion is blank.

Is there any fix for this or am i missing something in my code? Please help me with this.

Data returned from source(when I type ind):-

[
   {"id":"1","dat":"India"},   
   {"id":"2","dat":"Indonesia"}              
]

Thanks


Solution

  • the data returned should be of this format

    [
       {"value":"1","label":"India"},   
       {"value":"2","label":"Indonesia"}              
    ]