Class List

Define a List block to be displayed into a JBlocks.

Class Summary
Constructor Attributes Constructor Name and Description
 
List()

A List block holds display a list of items, handling the search and scroll.

Method Summary

Class Detail

List()

A List block holds display a list of items, handling the search and scroll.

The constructor should not be invoked directly but JBlocks#newBlock or JBlocks#addNewBlock should be used instead.

Method Detail

  • addItem(the)
    Add an item to the list.
    Parameters:
    {Object} the
    item data.
  • clearAll()
    Remove all list items.
  • ensureVisible()
    Ensures the item for the given key is visible in the list.
  • init(layout, options)
    Initializes a List block. The method is invoked by the jBlocks core and must never be called directly.
    Parameters:
    {Object} layout Optional
    see Block#init.
    {Object} options Optional
    in addition to base class options JBlock#init:
    {Boolean} options.haveSearch Optional, Default: false
    the list has a Search feature to allow filtering the displayed elements.
    {Boolean} options.showSearch Optional, Default: false
    if the list has a Search feature, this parameter defines whether the search input is initially displayed.
    {Function} options.createItem Optional
    function(item,li) is called to build the HTML content of the given <li/> element and must return a unique ID based on item. If null is returned, the item is not added to the list.
    {Array} options.items Optional
    an array of items to be displayed initially in the list.
    {Function} options.sortFn Optional, Default: null
    function(item1,items2) to sort the list.
    {Function} options.onRefresh Optional, Default: null
    function called after a refresh.
    {Function} options.onItemAdded Optional, Default: null
    function(item) called after an item has been added.
    {Function} options.onItemRemoves Optional, Default: null
    function(item) called after an item has been removed.
  • removeItem(the)
    Remove a list item.
    Parameters:
    {String} the
    key for the item to be removed.
  • scrollBottom()
    Scroll to the bottom of the list.
  • scrollTop()
    Scroll to the top of the list.
  • shuffle()
    Shuffles the order of the lines in the list.
  • sort()
    Sort the item in the list according to the provided sort function.
  • toggleSearch()
    Display or hide the search field.