Default call (auto-completion)

Description

Used to trigger auto-completion when input form is focused and there is no typed-in value (input is empty). This allows to display predefined list of suggestions to user.

Note It requires parameter (length=0).

Configuration options:

  • string - used to set as query to trigger auto-completion

  • [{value: '', label: ''}, {value: '', label: ''}] - list of hardcoded data to fulfill a dropdown menu

  • {data: [], filter: function(completion, data)} - use (filter function)[auto-completion_frontend_filter.md] to map a list of hardcoded data

  • {filter: function(completion, data), params: {}, url: ''} - use (filter function)[auto-completion_frontend_filter.md] to map data loaded from the server using a HTTP GET request by calling URL with given parameters

Examples

Display suggestions for query "funnelback"

defaultCall: 'funnelback'

Display fixed list of suggestions

defaultCall: [{value: "CSE", label:"CSE"}, {value: "Engineering", label:"Engineering"}]

Adjust fixed list of suggestions to required format and display it

defaultCall: {
    data: [{title: "CSE", url: 'http://www.cse.unsw.edu.au/'}, {title: "Engineering", url: 'http://www.engineering.unsw.edu.au/'}],
    filter: function(item, data) {
        return jQuery.map(data, function(item, i) { return {value: item.title, label: item.title, extra: {action: item.url, action_t: 'U'}, rank: i + 1}; });
    }
}

Request data from remote URL and display as list of suggestions

defaultCall: {
    filter: myCustomFunctionToMapData
    params: {},
    url: 'http://my-domain/custom-suggestions-list'
}