Constructor
(abstract) new AbstractAutocompleteAdapter(updateCallback, searchBoxSelector)
Parameters:
Name | Type | Description |
---|---|---|
updateCallback |
function | Callback to run after a row has been selected. |
searchBoxSelector |
String | jQuery selector for input we're adding the autocomplete widget to. |
Extends
Members
ac :AC
After AbstractAutocompleteAdapter#setupAutocomplete is run, holds a reference to the autocomplete widget used by this instance.
Type:
- AC
acCSSPrefix :String
CSS prefix for the autocomplete widget.
Type:
- String
acDelay :Number
Delay in milliseconds before performing a search.
Type:
- Number
acPrimaryTextKey :String
Key (into the row
objects retrieved via the request handler)
that determines which value is used as the main text in the autocomplete
widget.
'label'
corresponds to what the main application expects, but if you
want to show something different than what gets passed to the
application, you may want to change it.
Type:
- String
acSecondaryTextKey :String
Default row key for the optional secondary, smaller text shown in the autocomplete widget below each result.
Type:
- String
sourceID :String
Canonical identifier for this source. Lower-case string, no whitespace.
Type:
- String
- Overrides:
- Source:
supportedPattern :RegExp
RegExp for URLs this adapter can handle.
Type:
- RegExp
- Overrides:
- Source:
Methods
_renderNoResultsHandler()
Render "No search results" text row at the bottom with default styles.
This:
(abstract) _renderRowHandler(row)
Callback for rendering a row within the autocomplete widget, overriding default rendering.
This:
Parameters:
Name | Type | Description |
---|---|---|
row |
Object | The row object to render |
(abstract) _requestHandler(query)
Callback for fetching row data.
This:
Parameters:
Name | Type | Description |
---|---|---|
query |
String | The characters entered by the user |
_selectRowHandler(row, event)
Pass along row data we can handle to the main application. Will also query lib.reviews itself (through the native adapter) for the URL, so we can give preferential treatment to an existing native record for the review subject.
This:
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
row |
Object | row data object. All properties except "url" are only used for display purposes, since the server performs its own lookup on the URL. Properties
|
||||||||||||||||||||
event |
Event | the click or keyboard event which triggered this row selection. |
ask(url) → {Boolean}
Does this adapter support the given URL? By default, performs a simple regex check.
Parameters:
Name | Type | Description |
---|---|---|
url |
String | the URL to test |
- Overrides:
- Source:
Returns:
true if supported
- Type
- Boolean
disableSpinner()
Hide activity indicator in the input widget. Must be called in handler code via this.adapter.
enableSpinner()
Show activity indicator in the input widget. Must be called in handler code via this.adapter.
getSourceID() → {String}
Return the canonical source identifier for this adapter
- Overrides:
- Source:
Returns:
- Type
- String
(abstract) lookup(_url) → {Promise}
Perform a lookup for a given URL.
Parameters:
Name | Type | Description |
---|---|---|
_url |
String | the URL to perform lookup for |
- Overrides:
- Source:
Returns:
promise that resolves with a result object of the form LookupResult on success, and rejects with an error on failure
- Type
- Promise
removeAutocomplete()
Remove the autocomplete widget including all its event listeners.
runAutocomplete()
Run the autocomplete widget on the current input.
setupAutocomplete()
Initialize the autocomplete widget. You can add additional callbacks /
custom properties in the inherited class; just remember to call
super.setupAutocomplete()
first.