views:

22

answers:

0

Hello community,

First I wanted to say that jstree is a great and powerful utility.

My first problem is that I have created a multilingual tree with a json and I don't quite know how to set links there, so when the user clicks on a node (for parents and children) he can get to a page like www.yahoo.com or any link I set as an attribute. I have read the documentation at http://www.jstree.com/documentation, but my code still doesn't work.

The second problem is that my previous code that used to remember what branch was open (cooky plugin) doesn't work anymore with the json. Here I have set the appropriate l_json but it won't work.

Beneath I'm using the short format demo, as it seems more appropriate for me but I wouldn't mind using the json long format (respectively on jstree.com/documentation). However with it I don't know how to create children with href attributes.

So the code for the json is (packed in jstreeSetup.js):

$(function () { $("#l_json").tree({ languages : [ "de", "ru", "zh", "en", "es"], [{"attr":{"id":"node_2","rel":"folder"},"data":"root","state":"closed"}]

        data : { 
            type : "json",
            opts : {
                static : [
                    {
                        // Wilkommen und eine Ebene darunter
                        data : {"de" : "Willkommen", "ru" : "Добро пожаловать", "zh" : "欢迎", "en" : "Welcome",                                    "es" : "bienvenido"

                        },

                        // here are the children
                        children : [
                            { data : { "de" : "alternativ Wilkommen", "ru" : "Добро пожаловать 2", "zh" : "欢迎 2",                                         "en" : "Welcome 2", "es" : "bienvenido 2"} },
                        ]

                    },

The code in my website is:

$(function () { $("#l_json").tree({ plugins : { cookie : { prefix : "jstree_" } }, ui : { theme_name : "apple" }, callback : { onselect : function (node, tree_object) { node_real = $.tree.focused().get_node(node); //node_real1 = $.tree.focused().get_node(node); link = node_real.contents(); window.location.href = node(tree_object).attr("href"); } }, } }); });

Thank You for any help, Georg