corejavascript / corejavascript/typeahead.js

How to render a keyboard selectable option to save input data if it was not found

Open
#133 0 comments 0 reactions 0 assignees View on GitHub
question
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.