Class: H_ui_precomplete

H_ui_precomplete

Creates a "precomplete" input with selectable and filterable options.
the difference with "autocomplete", is that the possible data are given to the widget at start
and not researched in DB after each keystroke.
Supports keyboard navigation, callbacks, and value confirmation.
Possible settings:
- name (string): Unique name for internal IDs
- submit (boolean): Whether to auto-submit form on selection
- confirm (string): Optional confirmation message before submission
- callback (string|function): Callback to trigger after selection
- data (Array): List of selectable data objects with `id` and `name`
- new_value (boolean): Allow typing custom value not in list
- toreturn (boolean): Return selected ID instead of text value

new H_ui_precomplete(dom_id, settings)

ui.js, line 3492
Name Type Description
dom_id string dom_id for the created precomplete.
settings * of the precomplete widget.

Members

instances

All precomplete instances by dom_id (own registry, see H_ui_completer).

Methods

display_add_button()

ui.js, line 3677
Displays a button to add a new value.

get_next_item(){Object|false}

ui.js, line 3629
Gets the next visible list item.
Starts after the active row, or from the first one when nothing is highlighted, and goes back to the start at the end of the list.
Returns:
Type Description
Object | false Next visible row object or false if none.

get_previous_item(){Object|false}

ui.js, line 3655
Gets the previous visible list item.
Starts before the active row, or from the last one when nothing is highlighted, and goes to the end of the list when the first one is passed.
Returns:
Type Description
Object | false Previous visible row object or false if none.

key_navigation(evt)

ui.js, line 3586
Handles keyboard navigation for the dropdown.
Name Type Description
evt KeyboardEvent The key event.

on_click_row(evt, new_value)

ui.js, line 3538
Handles click on a suggestion row.
Name Type Default Description
evt Event Click event.
new_value string | number false optional Optional custom value to assign.

on_input(open)

ui.js, line 3567
Filters the list based on user input.
Name Type Default Description
open boolean true optional Whether to reopen the dropdown.