Interface TreeItem {
    id:Number,
    type:String,
    parent_id:Number,
    parent_type:String,
    title:String,
    subtype?:String
}

mw.tree

Usage

    var options = {
        data: [],
        element: document.body
    }
    var myTree = new mw.tree(options);

Options

  • id: String. Optional. Id of the tree, default: random
  • element: String selector, jQuery Object, Element. Required. Element inside which the tree will be rendered
  • selectable: Boolean. Optional. Whenever the tree will have radios and checkboxes.
  • data: TreeItem[]. Required. Data for the tree.
  • singleSelect: Boolean. Optional. Only one item can be picked
  • selectedData: TreeItem[]. Optional. Irtems that are initialy selected.
  • skip: TreeItem[]. Optional. Items that are going to be skipped from rendering.
  • sortable: Boolean. Optional.
  • nestedSortable: Boolean. Optional.
  • openedClass: String. Optional. Class applied to an opened LI node when it's opened. Default - opened
  • selectedClass: String. Optional. Class applied to an opened LI node when it's selected. Default - selected
  • skin: String. Optional. Skin of the tree. By default: 'default'
  • multiPageSelect: Boolean. Optional. Multiple pages can be selected.
  • saveState: Boolean. Optional. Whenever the tree state will be saved to the local storage. By default: if the id is provided -> true. If not->false,
  • append: TreeItem[]. Optional. Aditional Items that are appended to the tree
  • prepend: TreeItem[]. Optional. Aditional Items that are prepended to the tree

Methods

myTree.select(item, type?:String)

  • item - Can be:
    1. list item node,
    2. number ID of the TreeItem should be combined with type
    3. Object TreeItem
    4. Array containing TreeItem

myTree.deselect(item, type?:String)

  • item - Can be:
    1. list item node,
    2. number ID of the TreeItem should be combined with type
    3. Object TreeItem
    4. Array containing TreeItem

myTree.open(item, type?:String)

  • item - Can be:
    1. list item node,
    2. number ID of the TreeItem should be combined with type
    3. Object TreeItem
    4. Array containing TreeItem

myTree.close(item, type?:String)

  • item - Can be:
    1. list item node,
    2. number ID of the TreeItem should be combined with type
    3. Object TreeItem
    4. Array containing TreeItem

Events

orderChange

Usage:

    $(myTree).on('orderChange', function(event, itemDropped, data, oldData, localData){
        console.log(itemDropped, data, oldData, localData)
    });

orderChange

Usage:

    $(myTree).on('selectionChange', function(event, selectedData){
        console.log(selectedData)
    });

ready

Usage:

    $(myTree).on('ready', function(){

    });
The documentation is under development. Help us by editing this page.