Configuration

jquery.mentionsInput does have a number of extra configuration options which you may change to customise the way it behaves.

The meaning of the options and their default values are listed below.

onDataRequest

function(mode, query, callback)

This function is a callback function which is used to provide data for the autocomplete. When a search starts
this function is called with following arguments: 'search', the query (what's been typed), and a callback function which needs to be called inside onDataRequest with a data collection to be searched on as a first argument.

triggerChar

@

Trigger character which triggers the mentions search, when the character has been typed into the
mentions input field.

minChars

2

The minimum amount of characters after the trigger character necessary to perform a search.

showAvatars

true | false

Toggles whether or not items within the autocomplete-dropdown will be rendered with an icon/avatar.

classes

object

Object which contains classes used in the layout as key/value pairs.

templates

object

Object which contains templates used to render the layout as key/value pairs.

Methods

jquery.mentionsInput does expose a number of public methods, you can call on an instance.

init

Initialises the mentionsInput component on a specific element.

reset

Resets the component, clears all mentions.

val(callback)

An async method which accepts a callback function and returns a value of the input field (including markup) as a first parameter of this function.

This is the value you want to send to your server.

getMentions(callback)

An async method which accepts a callback function and returns a collection of mentions as hash objects as a first parameter.

Query data structure

When the component is preforming a "query" on the data specified through the onDataRequest-callback, it's expecting a specific data structure to be returned.