I installed the JQuery token-input plugin. https://github.com/loopj/jquery-tokeninput
Autocomplete is working, but I have a situation where I am search across multiple model attributes. For example, I have a drug Model and the model attributes include name and active ingredient
I am using the meta_where gem to search across multiple fields, and it is working correctly; checking the json output shows that my Drug.where() method is returning the correct result rows. However, on the front-end side, jQuery is populating the autocomplete box with only the name of the drug. How do I get jQuery to display multiple model attributes in the autocomplete box? Ideally, I would like to display something like “model.name (model.active_ingredient)” in the autocomplete dropdown. Right now, jQuery tokeninput is fetching the correct rows, but displaying only the name. How do I get the other attributes of the model to show up?
Thanks
you could combine the name and active_ingredient for the json,
because, all you can use is the name: “Aspirin (Mentol)”
when you return it from the controller, and seperate it, like you need it.
(in your Drug model)
all you need is to set the name: parameter in the json fill with your fullname attribute
to set it manually:
hope that helps you further