crowdint / rails3-jquery-autocomplete

An easy and unobtrusive way to use jQuery's autocomplete with Rails 3

Home Page:http://rubygems.org/gems/rails3-jquery-autocomplete

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Help needed: autocompleter gives list with blank items

lionelrudaz opened this issue · comments

Hello,

I'm trying to implement your gem in my Rails app, but I have a problem I can't figure out.

Comparing to the Product / Brands examples, I have some additional complexities. My Goal class has two relationships with another Player class: scorer and assist. In addition to that, I don't have a field called name in Player, but only firstname and lastname. I tried to implement virtual attributes fullname and name to emulate what I'd like to show in the autocomplete list, but without any success.

At this stage, my form has the textfield implemented. When I type, I see a list of elements, but each of them are empty. Despite that, I can select an element in the list, it returns the correct ID in another field. When I save, since the ID is filled, everything works just fine. Basically, I'm just lost on how to show players name in the list, not empty items.

I've added a :display_value option, but it doesn't change anything. It must be damn simple, but I turned the issue upside down and can't find a solution.

Here's a link to GitHub's repository: https://github.com/lionelrudaz/myteam2

Here's the JSON that the autocompleter returns:

[{"address":"Route du Chalet à Gobet 1","birthdate":"1990-01-31","city":"Froideville","created_at":"2012-10-19T00:51:46+02:00","email":"cedricp17@hotmail.com","firstname":"Cédric","id":6,"lastname":"Pahud","passport":210298,"pg_search_rank":0.121585,"phone":"+41 79 736 83 89","picture":{"url":"/uploads/player/picture/6/IMG_2593.jpg","thumb":{"url":"/uploads/player/picture/6/thumb_IMG_2593.jpg"},"mini":{"url":"/uploads/player/picture/6/mini_IMG_2593.jpg"},"retina_mini":{"url":"/uploads/player/picture/6/mini_IMG_2593%402x.jpg"}},"short_size":"XL","sox_size":"4","team_id":3,"tshirt_size":"M","updated_at":"2013-07-27T23:54:09+02:00","zipcode":"1055","name":"Cédric Pahud"},{"address":"","birthdate":"1995-05-11","city":"Etagnières","created_at":"2013-07-01T20:12:36+02:00","email":"","firstname":"Cédric","id":16,"lastname":"Despont","passport":455479,"pg_search_rank":0.0607927,"phone":"+41 77 431 93 84","picture":{"url":"/uploads/player/picture/16/IMG_2590.jpg","thumb":{"url":"/uploads/player/picture/16/thumb_IMG_2590.jpg"},"mini":{"url":"/uploads/player/picture/16/mini_IMG_2590.jpg"},"retina_mini":{"url":"/uploads/player/picture/16/mini_IMG_2590%402x.jpg"}},"short_size":"L","sox_size":"4","team_id":3,"tshirt_size":"L","updated_at":"2013-07-27T23:54:38+02:00","zipcode":"1037","name":"Cédric Despont"}]

Thanks in advance for your help.

Cheers,

@lionelrudaz are you still facing the issue or has it been resolved ?

Hi,

Yes, it's OK now. Can't remember exactly how I managed that, but it was finally OK.

Thanks