Now.js Framework Documentation

Now.js Framework Documentation

SearchElementFactory

TH 04 Sep 2026 01:40

SearchElementFactory

หน้านี้สร้างจากซอร์สโดยตรงเมื่อ 2026-08-21 คำอธิบายมาจาก JSDoc ในไฟล์
รันซ้ำได้ด้วย docs_scaffold เมื่อโค้ดเปลี่ยน อย่าแก้ด้วยมือถ้าตั้งใจให้ generate ต่อ

ที่มา

  • ไฟล์: Now/js/SearchElementFactory.js (360 บรรทัด)
  • รูปแบบ: ES class

เมธอดสาธารณะ (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 attribute ที่ใช้

data-form

พึ่งพาคลาสอื่น

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

เหตุการณ์

Event เมื่อเกิด Detail
search:performed ผู้ใช้สั่งค้นหา {elementId, query}