new module:ct-menu /model /Menu(options)
The Menu
is the model representation of a menu. This class presents a simple API
you can use in order to access/modify the internal state of the model.
In order to listen to item events, you can either listen for the event 'action' on the actual item or,
if a child module:ct-menu/Model
has 'eventName' inside its options, listen to that value.
Extends:
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Map |
A map of options. Properties
|
Extends
Methods
append(item)
Allows you to append either a single item or an array of items to the menu. This item(s) must implement the
module:ct-menu/model/Item
class.
Parameters:
Name | Type | Description |
---|---|---|
item |
Variant | The array of items or the single item that needs to be appended. |
Throws:
-
If item is not a instance of
module:ct-menu/model/Item
. - Type
-
module:ct-core
/Error
disable()
Disables the item.
- Inherited From:
enable()
Enables the item.
- Inherited From:
get(index) → {Object}
Returns the item in the given position.
Parameters:
Name | Type | Description |
---|---|---|
index |
Number | The item index. |
Throws:
-
If index is outside of the bounds of the current menu list.
- Type
-
module:ct-core
/Error
Returns:
- Type
- Object
get All() → {Array}
Returns a copy of the list of all menu items in this menu.
Returns:
An array of menu items contained in this menu.
- Type
- Array
get ByClassifier(classifier, allow Partial Match) → {Array}
Returns a list of items with the given classifier.
Parameters:
Name | Type | Description |
---|---|---|
classifier |
String | The classifier to search for. |
allowPartialMatch |
Boolean | Allows partial matches for the search. |
Returns:
A list of {module:ct-menu/model/Item} objects with the given classifier, or an empty array if none are found.
- Type
- Array
get ByLabel(label, allow Partial Match) → {Array}
Returns a list of items with the given label.
Parameters:
Name | Type | Description |
---|---|---|
label |
String | The label to search for. |
allowPartialMatch |
Boolean | Allows partial matches for the search. |
Returns:
A list of {module:ct-menu/model/Item} objects with the given label, or an empty array if none are found.
- Type
- Array
get Classifier() → {String}
Returns the item's classifier.
- Inherited From:
Returns:
- Type
- String
get Label() → {String}
Returns the item's label.
- Inherited From:
Returns:
- Type
- String
insert(index, item)
Inserts an item in the given position.
Parameters:
Name | Type | Description |
---|---|---|
index |
Number | The index in which the item will be inserted. |
item |
Object | The item to be inserted. |
Throws:
-
-
If item is not a instance of
module:ct-menu/model/Item
. - Type
-
module:ct-core
/Error
-
-
-
If index is outside of the bounds of the current menu list.
- Type
-
module:ct-core
/Error
-
remove(index)
Removes an item from the specified index.
Parameters:
Name | Type | Description |
---|---|---|
index |
Number | The index from which the item will be removed. |
Throws:
-
If index is outside of the bounds of the current menu list.
- Type
-
module:ct-core
/Error
remove All()
Removes all the items inside the menu.