Expand all

mw.widgets.CategoryMultiselectWidget

Displays an OO.ui.MenuTagMultiselectWidget and autocompletes with available categories.

Example

mw.loader.using( 'mediawiki.widgets.CategoryMultiselectWidget', function () {
  let selector = new mw.widgets.CategoryMultiselectWidget( {
    searchTypes: [
      mw.widgets.CategoryMultiselectWidget.SearchType.OpenSearch,
      mw.widgets.CategoryMultiselectWidget.SearchType.InternalSearch
    ]
  } );

  $( document.body ).append( selector.$element );

  selector.setSearchTypes( [ mw.widgets.CategoryMultiselectWidget.SearchType.SubCategories ] );
} );

Extends

Constructor

new mw.widgets.CategoryMultiselectWidget([config]) #

Create an instance of mw.widgets.CategoryMultiselectWidget.

Parameters:

Name Type Attributes Description
config Object optional

Configuration options

Properties:
Name Type Attributes Default Description
api mw.Api optional

Instance of mw.Api (or subclass thereof) to use for queries

limit number optional
10

Maximum number of results to load

searchTypes Array.<mw.widgets.CategoryMultiselectWidget.SearchType> optional
[mw.widgets.CategoryMultiselectWidget.SearchType.OpenSearch]

Default search API to use when searching.

Mixes in:
Source:

Properties

SearchTypestatic #

Properties:

Name Type Description
OpenSearch

Search using action=opensearch

InternalSearch

Search using action=query

Exists

Search for existing categories with the exact title

SubCategories

Search only subcategories

ParentCategories

Search only parent categories

Source:

Methods

setSearchTypes(searchTypes) #

Sets and validates the value of this.searchType.

Parameters:

Name Type Description
searchTypes Array.<mw.widgets.CategoryMultiselectWidget.SearchType>
Source:
Sets and validates the value of this.searchType.