About

Suggestions plugin allows to easily specify the list of suggestion items that the Autocomplete plugin would present to the user.

Examples

Options

Suggestions plugin only has one option and that is to set suggestion items. It could be changed when passed to the $().textext() function. For example:

$('textarea').textext({
    plugins: 'suggestions',
    suggestions: [ "item1", "item2" ]
})

suggestions (null)

List of items that Autocomplete plugin would display in the dropdown.

Events

Suggestions plugin dispatches or reacts to the following events.

getSuggestions

Suggestions plugin reacts to the getSuggestions event and returns suggestions items from the options.

postInit

Suggestions plugin reacts to the postInit event to pass its list of suggestions to the Autocomplete right away.

setSuggestions

Suggestions plugin triggers the setSuggestions event to pass its own list of Suggestions to the Autocomplete plugin.

Methods

TextExtSuggestions.init(core)

  • core {TextExt} Instance of the TextExt core class.

Initialization method called by the core during plugin instantiation.

TextExtSuggestions.onGetSuggestions(e, data)

  • e {Object} jQuery event.

  • data {Object} Payload from the getSuggestions event with the user query, eg { query: {String} }.

Reacts to the getSuggestions event and triggers setSuggestions event with the list of suggestions specified in the options.

TextExtSuggestions.onPostInit(e)

  • e {Object} jQuery event.

Reacts to the postInit event and triggers setSuggestions event to set suggestions list right after initialization.

TextExtSuggestions.setSuggestions(suggestions, showHideDropdown)

  • suggestions {Array} List of suggestions. With the default ItemManager it should be a list of strings.

  • showHideDropdown {Boolean} If it’s undesirable to show the dropdown right after suggestions are set, false should be passed for this argument.

Triggers setSuggestions and passes supplied suggestions to the Autocomplete plugin.

Fork me on GitHub