私有方法
译者注:私有方法只有插件内部会调用,我们开发一般用不上,就不翻译了jsTree core functionality
plugin (deco [, opts]
used to decorate an instance with a plugin. Used internally.
deco | String the plugin to decorate with |
opts | Object options for the plugin |
Returns | jsTree |
init (el, optons)
initialize the instance. Used internally.
el | DOMElement jQuery String the element we are transforming |
options | Object options for this instance |
Triggers | init.jstree loading.jstree loaded.jstree ready.jstree changed.jstree |
teardown ()
part of the destroying of an instance. Used internally.
bind ()
bind all events. Used internally.
unbind ()
part of the destroying of an instance. Used internally.
trigger (ev [, data])
trigger an event. Used internally.
ev | String the name of the event to trigger |
data | Object additional data to pass with the event |
get_container_ul ()
returns the jQuery extended main UL node inside the instance container. Used internally.
Returns | jQuery |
get_string (key)
gets string replacements (localization). Used internally.
key | String |
Returns | String |
_firstChild (dom)
gets the first child of a DOM node. Used internally.
dom | DOMElement |
Returns | DOMElement |
_nextSibling (dom)
gets the next sibling of a DOM node. Used internally.
dom | DOMElement |
Returns | DOMElement |
_previousSibling (dom)
gets the previous sibling of a DOM node. Used internally.
dom | DOMElement |
Returns | DOMElement |
_load_nodes (nodes [, callback])
load an array of nodes (will also load unavailable nodes as soon as they appear in the structure). Used internally.
nodes | array |
callback | function a function to be executed once loading is complete, the function is executed in the instance's scope and receives one argument - the array passed to _load_nodes |
_load_node (obj [, callback])
handles the actual loading of a node. Used only internally.
obj | mixed |
callback | function a function to be executed once loading is complete, the function is executed in the instance's scope and receives one argument - a boolean status |
Returns | Boolean |
_node_changed (obj [, callback])
adds a node to the list of nodes to redraw. Used only internally.
obj | mixed |
_append_html_data (obj, data)
appends HTML content to the tree. Used internally.
obj | mixed the node to append to |
data | String the HTML string to parse and append |
Triggers | model.jstree changed.jstree |
_append_json_data (obj, data)
appends JSON content to the tree. Used internally.
obj | mixed the node to append to |
data | String the JSON object to parse and append |
force_processing | Boolean internal param - do not set |
Triggers | model.jstree changed.jstree |
_parse_model_from_html (d [, p, ps])
parses a node from a jQuery object and appends them to the in memory tree model. Used internally.
d | jQuery the jQuery object to parse |
p | String the parent ID |
ps | Array list of all parents |
Returns | String the ID of the object added to the model |
_parse_model_from_flat_json (d [, p, ps])
parses a node from a JSON object (used when dealing with flat data, which has no nesting of children, but has id and parent properties) and appends it to the in memory tree model. Used internally.
d | Object the JSON object to parse |
p | String the parent ID |
ps | Array list of all parents |
Returns | String the ID of the object added to the model |
_parse_model_from_json (d [, p, ps])
parses a node from a JSON object and appends it to the in memory tree model. Used internally.
d | Object the JSON object to parse |
p | String the parent ID |
ps | Array list of all parents |
Returns | String the ID of the object added to the model |
_redraw ()
redraws all nodes that need to be redrawn. Used internally.
Triggers | redraw.jstree |
draw_children (node)
redraws a single node's children. Used internally.
node | mixed the node whose children will be redrawn |
redraw_node (node, deep, is_callback, force_render)
redraws a single node. Used internally.
node | mixed the node to redraw |
deep | Boolean should child nodes be redrawn too |
is_callback | Boolean is this a recursion call |
force_render | Boolean should children of closed parents be drawn anyway |
_open_to (obj)
opens every parent of a node (node should be loaded)
obj | mixed the node to reveal |
activate_node (obj, e)
called when a node is selected by the user. Used internally.
obj | mixed the node |
e | Object the related event |
Triggers | activate_node.jstree changed.jstree |
hover_node (obj)
applies the hover state on a node, called when a node is hovered by the user. Used internally.
obj | mixed |
Triggers | hover_node.jstree |
dehover_node (obj)
removes the hover state from a nodecalled when a node is no longer hovered by the user. Used internally.
obj | mixed |
Triggers | dehover_node.jstree |
get_state ()
gets the current state of the tree so that it can be restored later with set_state(state). Used internally.
Returns | Object |
set_state (state [, callback])
sets the state of the tree. Used internally.
state | Object the state to restore. Keep in mind this object is passed by reference and jstree will modify it. |
callback | Function an optional function to execute once the state is restored. |
Triggers | set_state.jstree |
set_text (obj, val)
set the text value of a node. Used internally, please use rename_node(obj, val).
obj | mixed the node, you can pass an array to set the text on multiple nodes |
val | String the new text value |
Returns | Boolean |
Triggers | set_text.jstree |
check (chk, obj, par, pos)
check if an operation is premitted on the tree. Used internally.
chk | String the operation to check, can be "create_node", "rename_node", "delete_node", "copy_node" or "move_node" |
obj | mixed the node |
par | mixed the parent |
pos | mixed the position to insert at, or if "rename_node" - the new name |
more | mixed some various additional information, for example if a "move_node" operations is triggered by DND this will be the hovered node |
Returns | Boolean |
Checkbox plugin
This plugin renders checkbox icons in front of each node, making multiple selection much easier.
It also supports tri-state behavior, meaning that if a node has a few of its children checked it will be rendered as undetermined, and state will be propagated up.
_undetermined ()
set the undetermined state where and if necessary. Used internally.
_cascade_new_checked_state (id, checkedState)
Cascades checked state to a node and all its descendants. This function does NOT affect hidden and disabled nodes (or their descendants).
However if these unaffected nodes are already selected their ids will be included in the returned array.
id | string the node ID |
checkedState | bool should the nodes be checked or not |
Contextmenu plugin
Shows a context menu when a node is right-clicked.
_show_contextmenu (obj, x, y, i)
show the prepared context menu for a node
obj | mixed the node |
x | Number the x-coordinate relative to the document to show the menu at |
y | Number the y-coordinate relative to the document to show the menu at |
i | Number the object of items to show |
Triggers | show_contextmenu.jstree |
Sort plugin
Automatically sorts all siblings in the tree according to a sorting function.
sort (obj [, deep])
used to sort a node's children
obj | mixed the node |
deep | Boolean if set to true nodes are sorted recursively. |
Triggers | search.jstree |