Now.js Framework Documentation

Now.js Framework Documentation

SearchElementFactory

EN 04 Sep 2026 01:40

SearchElementFactory

Generated from source on 2026-08-21. Descriptions come from JSDoc in the file.
Re-run docs_scaffold when the code changes; hand edits are lost on regeneration

Source

  • File: Now/js/SearchElementFactory.js (360 lines)
  • Form: ES class

Public methods (8)

static cleanup(instance)

Remove the clear button and results container added by this factory. Wrapped in try/catch so a DOM that has already been partially torn down does not throw while cleaning up the rest.

static async handleSearch(instance, value)

Run a search for the current value and render the results. Shows or hides the clear button based on whether there is a value, and toggles the loading state around the request.

static registerWithFormManager(instance)

Tell FormManager about a search field inside a data-form. Does nothing when FormManager is not loaded, or the field is not inside a declarative form, so a standalone search input works without it.

static setLoadingState(instance, isLoading)

Toggle the loading class on the field's wrapper.

static setupClearButton(instance)

Add the button that clears the field and hides results.

static setupElement(instance)

Turn a text field into a search field. Extends the text element setup, then adds the search-specific pieces: the results container, the clear button, and (when the field lives inside a data-form) registration with FormManager.

static setupResultsContainer(instance)

Create the dropdown that search results render into. Starts hidden; failures are swallowed so a broken results container does not stop the rest of the field from working.

static showResults(instance, items = [], query = '')

Render search results into the dropdown.

Data attributes used

data-form

Depends on

Autocomplete · ElementFactory · ElementManager · ErrorManager · EventManager · FormError · FormManager · TextElementFactory

Events

Event When Triggered Detail
search:performed A search was performed {elementId, query}