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 2976
Name Type Description
dom_id string dom_id for the created precomplete.
settings * of the precomplete widget.

Members

instancesObject

Stores all precomplete instances.

Methods

add_active(elem)

ui.js, line 3137
Sets a list item as the active selection.
Name Type Description
elem HTMLElement Element to activate.

close()

ui.js, line 3083
Hides the suggestion list.

display_add_button()

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

get_next_item(){Object|false}

ui.js, line 3174
Gets the next visible list item.
Returns:
Type Description
Object | false Next visible row object or false if none.

get_previous_item(){Object|false}

ui.js, line 3197
Gets the previous visible list item.
Returns:
Type Description
Object | false Previous visible row object or false if none.

key_navigation(evt)

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

on_click_row(evt, new_value)

ui.js, line 3025
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 3054
Filters the list based on user input.
Name Type Default Description
open boolean true optional Whether to reopen the dropdown.

remove_active()

ui.js, line 3146
Removes the currently active item.

scroll_to_active()

ui.js, line 3156
Scrolls the list to bring the active item into view iff needed.

show()

ui.js, line 3072
Shows the suggestion list.

staticH_ui_precomplete.create_instance(dom_id, settings){H_ui_precomplete}

ui.js, line 3257
Creates a new precomplete instance for a given dom_id.
Cleans up any existing instance for the same dom_id.
Name Type Description
dom_id string The DOM id suffix.
settings Object Settings for the instance.
Returns:
Type Description
H_ui_precomplete The created instance.