Search code examples
jqueryautocompleteorbeon

Orbeon autocomplete - keep what user entered (even if not matched to suggestions)


I'm using Orbeon forms - Autocomplete component and calling an external service to provide me with list of suggestions, based on what user has entered.

The requirement I have is to enable the user to keep what he has already entered, even if service cannot find appropriate match.

However, I have the problem that currently the service gets called when I move to another field (or when i simply click in and out of the autocomplete field), and it returns me the empty string or null which automatically gets populated as autocomplete field value (blank).

Do you have an idea how can I solve this? Since Orbeon autocomplete gets rendered as multiple fields, I'm not sure how JS logic is behind it.

Thanks, Lazar

[Update-workaround] Check reply to @avernet answer - workaround: Replaced existing (external) service call, with one going to my back-end controller, which executes the call the original, external service with search parameter the user provided. If controller receives back blank value as a suggestion (implying that there are no matches), it creates a empty XML structure which is the one Autocomplete expects, but with search parameter the user has entered as a value.


Solution

  • This use case isn't covered by the autocomplete control. You can think of the autocomplete as a selection control, say like the dropdown, but only for cases where the list of possible values is too long to show as-is, or even to load in the browser as-is, so you instead want to show just part of it, based on a "search" the user is doing.

    It seems that what you're looking for would be an autocomplete that supports selection="open". Even if this isn't exactly what you're looking for, we've implemented open selection for radio boxes, and are shooting to release this in 4.11.