Options
All
  • Public
  • Public/Protected
  • All
Menu

Autocompete.Controller

The Autocomplete Controller class acts as the public class which you may wield to enable address autocomplete on your HTML address forms

When instantiated, the controller will serve as a bridge beteen the address suggestion interface presented on the DOM and the Ideal Postcodes Address resolution HTTP APIs

More concretely, the instantiation of a controller instance creates:

The role of the controller is to bind to events produced by the user interface and take appropriate action including querying the API, modifying other aspects of the DOM.

Hierarchy

  • Controller

Index

Constructors

constructor

Methods

Private _onInterfaceInput

  • _onInterfaceInput(): any
  • Produces a function to be bound to an instance of Autocomplete.Interface. It executes suggestion search when address input is updated

    Returns any

Private _onInterfaceSelect

  • _onInterfaceSelect(): any
  • Produces a function to be bound to an instance of Autocomplete.Interface. Populates fields with correct address when suggestion selected

    Returns any

Private attachInterface

  • Binds internal instanec of Autocomplete.Interface to DOM and applies necessary callbacks

    Parameters

    Returns void

Private configureApiRequests

  • configureApiRequests(options: BasicOptions): void
  • Configures HTTP client options prior to instantiation

    Parameters

    • options: BasicOptions

    Returns void

detachInterface

  • detachInterface(): void
  • Detaches the autocomplete interaface from the DOM

    Returns void

Private initialiseCallbacks

  • Binds any optional callbacks supplied in configuration to controller or writes a NOOP if callback not provided

    Parameters

    Returns void

Private initialiseClient

  • initialiseClient(options: ClientOptions): void
  • Produces an instance of IdealPostcodes.Client

    Parameters

    • options: ClientOptions

    Returns void

initialiseInterface

  • This creates a new instance of Autocomplete.Interface and attaches it to the DOM.

    Furthermore, Checks if key is usable (if enabled)

    This method is invoked upon the instantiation of Autocomplete.Controller, however it may be used to detach/re-attach new instances of the interface

    Parameters

    Returns void

Private initialiseOutputFields

  • Updates an internal list of CSS selectors which will direct the flow of addressing information when user selects an address

    Parameters

    Returns void

populateAddress

  • Writes a selected to the input fields specified in the controller config

    Parameters

    Returns void

setSearchFilter

  • setSearchFilter(options: SearchFilters): void
  • Restrict autocomplete suggestions to certain features (e.g. post town, outward postcode)

    example

    controller.setSearchFilter({postcode_outward: ["SW1A"]})

    Parameters

    • options: SearchFilters

    Returns void