Skip to content

Autocomplete

Victor Pereira edited this page Apr 30, 2020 · 1 revision

if there is need for autocomplete in a form field. Please use the standard solution provided by OBS.

Check the autocomplete.js and excluded_requests#index.

We use the jQuery autocomplete plugin and we have a generic partial to handle it here

Basically:

  • Create an autocomplete method in the controller, responding with the query in json. The param name is term.

Important: The returned data should be an array of strings.

  • Add the shared/_autocomplete view to your form. It basically set all the necessary information in the autocomplete field.

Important: Pass the data: { source: ... } pointing to your new autocomplete method

Clone this wiki locally