corejavascript / corejavascript/typeahead.js
How to render a keyboard selectable option to save input data if it was not found
- Dominant language
- JavaScript
- Stars
- 968
- Forks
- 231
- PR merge metrics
- No merged PRs in 30d
Description
Hi everybody,
Context: Twitter TypeAhead with BloodHound retrievieng data from a MySQL database with PHP.
In short ( not so short :) ), I would like to display an option to allow the user record the data typed at the input if it was not found. I know I can put a button at the form to do that, but I want it to be a selectable option that will trigger a function to save the input data to DB with ajax.
By default, when no result was rendered, it will be used the notFound template. The problem is that that template is not accessed with the arrow down key like a normal option.
The first example shows normal situation and in the 2nd example is showed what I want (press arrow-down key to choose it and then press Enter to trigger the action.)
Example 1.
'--------
| B |
'-----------
Bolivia
Brazil
Bulgary...
'-----------
Example 2.
'--------
| Xpto |
'-----------------------------------
Not found... select to save it...
'-----------------------------------
Well... that's it... I hope someone has already walked through such a situation and has a solution to share.
Thanks.
Contributor guide
Assessment
This issue has not been assessed yet.