autocomplete icon indicating copy to clipboard operation
autocomplete copied to clipboard

Documentation is wrong for filtering objects

Open LouWii opened this issue 7 years ago • 2 comments

The example to filter through an array of objects is wrong. I spent an hour to search how to make it work.

From your site:

$('#auto1').autocomplete({source:[{
 data:[
  {id:1, title:"alabama"},
  {id:2, title:"alaska"},
  {id:3, title:"georgia"},
  {id:4, title:"texas"},
  {id:6, title:"california"}
 ],
 getTitle:function(item){
  return item['title']
 },
 getValue:function(item){
  return item['title']
 },
}]})

That doesn't work. The proper way I found is :

$('#auto1').autocomplete(
  {
    source:[{
      data:[
      {id:1, title:"alabama"},
      {id:2, title:"alaska"},
      {id:3, title:"georgia"},
      {id:4, title:"texas"},
      {id:6, title:"california"}
    ],
    valueKey: 'title'
}]});

LouWii avatar Jul 09 '16 22:07 LouWii

Appreciate the frustration, but Ouch, feeling the blame from your tone.

If you'd like to submit as a pull request we can look at getting this in. A little positive encouragement helps too.

evolve2k avatar Jul 11 '16 04:07 evolve2k

Sorry, I know I tend to get frustrated after spending too much time on searching how to do something 😇

I'm not sure what PR I should do, as the example is on your website ?

LouWii avatar Jul 11 '16 05:07 LouWii