new tart.DropdownList(initialList, opt_builder, opt_activeItem)
Constructor method for DropdownList.
Name | Type | Description |
---|---|---|
initialList |
Object | Array |
initial list of items. |
opt_builder |
tart.Builder |
optional
builder class. |
opt_activeItem |
number |
optional
index of the active item. |
Extends
Methods
-
inherited addItem(key, value){boolean}
-
Adds a new key-value pair to the collection.
Name Type Description key
number | string Key for the pair.
value
* Value for the pair.
Returns:
Type Description boolean Returns true if the add operation was successful. -
Returns active item as JSON object.
Returns:
Type Description tart.JSON returns the active key-value pair from the collection. -
inherited getActiveItemIndex(){number}
-
Returns active item's index.
Returns:
Type Description number returns the active index in the collection. -
inherited getActiveItemKey(){string|number}
-
Returns active item's key.
Returns:
Type Description string | number returns the active key from the collection. -
inherited getActiveItemValue(){*}
-
Returns active item's value.
Returns:
Type Description * returns the active value from the collection. -
inherited getAll(){Array}
-
Dumps all items in an array.
Returns:
Type Description Array returns all pairs as an array. -
Returns item by given index.
Name Type Description index
number Index to search in the collection.
Returns:
Type Description tart.JSON | boolean | undefined returns the key-value pair given an index. -
Returns item by given key. If not found, returns boolean false.
Name Type Description key
string | number key to search for.
Returns:
Type Description tart.JSON returns the key-value pair given a specific key. -
Returns item by given value. If not found, returns boolean false.
Name Type Description val
string | number value to search for.
Returns:
Type Description tart.JSON returns the key-value pair given a specific value. -
getDOM(){jQueryObject}
-
Returns current DOM element of dropdownlist instance.
Returns:
Type Description jQueryObject The jQuery object that wraps the DOM. -
Returns all items in a kvp format.
Returns:
Type Description tart.JSON obj returns an object that contains keys as its keys and values as its values. -
inherited getKeys(){Array}
-
Returns all keys in an array.
Returns:
Type Description Array returns all keys in an array. -
inherited getValues(){Array}
-
Returns all values in an array.
Returns:
Type Description Array returns all values in an array. -
inherited removeByIndex(index){number|boolean|undefined}
-
Removes an item from collection which given by index and rebuilds the item collection. Returns new activeItemIndex if item successfully removed or FALSE if not.
Name Type Description index
number Index to remove.
Returns:
Type Description number | boolean | undefined Condition of the operation or the active item index. -
inherited removeByKey(key)
-
Removes items by key.
Name Type Description key
string Game items key.
-
removeDOM()
-
Removes current DOM element of dropdownlist instance from window.document.
-
setActiveItemByValue(value)
-
Set active item belongs to value parameter.
Name Type Description value
string | number of an array.
-
inherited setActiveItemIndex(newIndex){boolean}
-
Sets active item index.
Name Type Description newIndex
number index to set as the new active item.
Returns:
Type Description boolean Whether the method was able to set the item. -
switchIndex(newIndex)
-
Triggered by this.builder.dom_ element when user change the index by non-programatically way. Important: This method shouldn't be called in any implementation code. Developers should use this.setActiveItemIndex() method instead of this.
Name Type Description newIndex
number index of the item to set as active.