class AFrame.List class extends AFrame.Display
A generic HTML list class. A list is any list of data. A List shares the majority of its interface with a CollectionArray since lists are inherently ordered (even if they are ULs). There are two methods for inserting an item into the list, either passing an already created element to insertElement or by passing data to insert. If using insert, a factory function (renderItem) must be specified in the configuration. The factory function can either create an element directly or use some sort of prototyping system to create the element. The factory function must return the element to be inserted.
<ul id="clientList">
</ul>
---------
// Set up a factory to create list elements. This can create the elements
// directly or use sort of templating system.
var factory = function( data, index ) {
var listItem = AFrame.DOM.createElement( 'li', data.name + ', '
+ data.employer );
return listItem;
};
var list = AFrame.List.create( {
target: '#clientList',
renderItem: factory
} );
// Creates a list item using the factory function, item is inserted
// at the end of the list
list.insert( {
name: 'Shane Tomlinson',
employer: 'AFrame Foundary'
} );
// Inserts a pre-made list item at the head of the list
list.insertRow( AFrame.DOM.createElement( 'li', 'Joe Smith, the Coffee' +
' Shop' ), 0 );
---------
<ul id="clientList">
<li>Joe Smith, The Coffee Shop</li>
<li>Shane Tomlinson, AFrame Foundary</li>
</ul>
Constructor
| Constructor | Parameters | Returns |
|---|---|---|
AFrame.List(
)
|
Methods
| Methods | Returns | Description |
|---|---|---|
clear(
)
|
void
|
↑
Clear the list |
forEach(
callback, context
)
|
void
|
↑
Call a callback for each element in the list. The callback will be called with the rowElement and the index Parameters:
|
insert(
data, index
)
|
number
|
↑
Insert a data item into the list, the list item is created using the renderItem.
Parameters:
Returns: |
insertElement(
rowElement, index
)
|
number
|
↑
Insert an element into the list.
Parameters:
Returns: |
remove(
index
)
|
void
|
↑
Remove an item from the list
Parameters:
|
renderItem(
data, index
)
|
Element
|
↑
The factory used to create list elements.
Parameters:
Returns: |
Methods inherited from AFrame.ObservablesMixin
| Methods | Notes |
|---|---|
bindEvent
|
↑ |
bindTo
|
↑ |
getEventObject
|
↑ |
isEventTriggered
|
↑ |
proxyEvents
|
↑ |
setEventData
|
↑ |
triggerEvent
|
↑ |
unbindAll
|
↑ |
unbindEvent
|
↑ |
unbindTo
|
↑ |
unbindToAll
|
↑ |
Methods inherited from AFrame.ArrayCommonFuncsMixin
| Methods | Notes |
|---|---|
addCreate
|
↑ |
AFrame.Class.walkChain
|
↑ |
Class
|
↑ |
getActualIndex
|
↑ |
getActualInsertIndex
|
↑ |
getCount
|
↑ |
Methods inherited from AFrame.AObject
| Methods | Notes |
|---|---|
addChild
|
↑ |
bindEvents
|
↑ |
checkRequired
|
↑ |
getCID
|
↑ |
getConfig
|
↑ |
init
|
↑ |
removeChild
|
↑ |
teardown
|
↑ |
triggerProxy
|
↑ |
Methods inherited from AFrame.EnumerableMixin
| Methods | Notes |
|---|---|
filter
|
↑ |
getCount
|
↑ |
search
|
↑ |
Methods inherited from AFrame.Display
| Methods | Notes |
|---|---|
bindClick
|
↑ |
bindDOMEvent
|
↑ |
bindDOMEvents
|
↑ |
getDOMElement
|
↑ |
getTarget
|
↑ |
render
|
↑ |
unbindDOMEvent
|
↑ |
unbindDOMEvents
|
↑ |
Events
| Events | Description |
|---|---|
onInsert(
options
)
|
↑
Triggered whenever a row is inserted into the list Parameters:
|
onInsertElement(
options
)
|
↑
Triggered whenever an element is inserted into the list Parameters:
|
onRemoveElement(
options
)
|
↑
Triggered whenever an element is removed from the list Parameters:
|
Events inherited from AFrame.AObject
| Events | Notes |
|---|---|
onInit
|
↑ |
onTeardown
|
↑ |
Events inherited from AFrame.Display
| Events | Notes |
|---|---|
onRender
|
↑ |
Configuration Attributes
| Attributes | Type | Description |
|---|---|---|
renderItem
|
{function} (optional)
|
↑
A function to call to create a list element. function will be called with two parameters, an data and index. If not specified, then the internal factory that returns an empty LI element will be used. See renderItem.
Default value:
this.renderItem
|
Configuration Attributes inherited from AFrame.AObject
| Attributes | Notes |
|---|---|
{cid} cid
|
↑ |
Configuration Attributes inherited from AFrame.Display
| Attributes | Notes |
|---|---|
bindEvents
|
↑ |
target
|
↑ |