group | subgroup | title |
---|---|---|
javascript-developer-guide |
3_Widgets |
List widget |
{% include note.html type='warning' content='The list widget is deprecated since version 2.2.0. As an alternative component for the admin area, use [DynamicRows][].' %}
Provides a way to move items, typically a list, from one content section to another. The content can be moved using buttons and links.
The list widget source file is [lib/web/mage/list.js].
For information about how to initialize a widget in a JS component or .phtml
template, see the [Initialize JavaScript] topic.
The list widget has the following options:
- addButton
- destinationSelector
- itemCount
- itemIndex
- maxItems
- maxItemsAlert
- removeButton
- template
- templateClass
- templateWrapper
Detailed description of each option follows.
Selector for the element used for item adding.
Type: String
Default value: [data-button=add]
Content destination selector.
Type: String
Default value: [data-role=container]
Number of total items.
Type: Integer
Default value: 0
Number of the current item.
Type: Integer
Default value: 0
Number of list items that can be added to the destination.
Type: Integer
Default value: null
Alert message displayed when maximum limit is reached.
Type: String
Default value: null
Selector for the element used for item removing.
Type: String
Default value: [data-button=remove]
Template for the added item.
Type: String
Default value: [data-role=item]
Class attached to the template wrapper.
Type: String
Default value: null
Element holding the template.
Type: String
Default value: null
The list widget has the following methods:
Adds item to the list in the specified order (defined by the index parameter).
Adds item to the list.
If the maxItems
option is set, hides or displays the Add button.
Removes an item from the list.
[lib/web/mage/list.js]: {{ site.mage2bloburl }}/{{ page.guide_version }}/lib/web/mage/list.js [Initialize JavaScript]: {{page.baseurl}}/javascript-dev-guide/javascript/js_init.html [DynamicRows]:{{ page.baseurl }}/ui_comp_guide/components/ui-dynamicrows.html