back to the documentation homepage
jsTree v.1.0 - languages plugin
Description
The languages plugin enables multilanguage trees. This means that each node has a specified number of titles - each in a different "language". Only one language set is visible at any given time. This is useful for maintaining the same structure in many languages (hence the name of the plugin)
Configuration
Expects an array of language codes. Each of the items is used as a CSS class name, so make sure you specify only valid CSS class name strings. The first langauge will be visible onload. For example:
[ "en", "de", "bg" ]
Demos
Check your data plugin documentation (html_data, xml_data, json_data) or take a close look at these examples for information on how to specify multilanguage nodes.
Using the languages plugin with HTML data
API
.set_lang ( lang )
Set the tree's visible language. Triggers an event.
-
stringlang
numberEither the language code string (as specified in the config) or an index from the config array.
.get_lang ( )
Returns the name of the currently visible language.
.get_text ( node , lang )
Returns the title of a node. Overwrites the get_text function from the core.
-
mixednodeThis can be a DOM node, jQuery node or selector pointing to the element whose title you need.
-
stringlangThe language code string (as specified in the config) to get the title in. If you omit this - the currently visible language is used.
.set_text ( node , text , lang )
Sets the title of a node. Overwrites the set_text function from the core. This is used internally - you should use rename_node. Since rename_node uses set_text internally you can pass a language string as a third parameter to rename_node.
-
mixednodeThis can be a DOM node, jQuery node or selector pointing to the element whose title you want to change.
-
stringtextThe new title.
-
stringlangThe language code string (as specified in the config) to get the title in. If you omit this - the currently visible language is used.
._load_css ( )
used only internally to include the CSS necessary for the plugin onload.
.create_node ( obj , position , js , callback )
Overwrites the create_node function from the core. To create a node with a few titles use an array for the data property of the js parameter:
{ "data" : [ { "title" : "EN title", language : "en" }, { "title" : "BG заглавие", language : "bg" } ] }