mardi 29 août 2017

How to async loading ember jstree for selected node

I am trying to use jstree plugin in ember js in one of my projects. I am using this plugin to load a folder structure, but I would like to do this operation async. The examples I've found on their site (called async) are ridiculous. I've tried to check on the Internet but it seems that most people load the whole tree. I would like to load a branch on every single node click. I am using JSON. data: [ 'Simple root node', { 'id': 'rn1', 'text': 'Single child node (has tooltip)', 'type': 'single-child', 'state' : { 'opened' : true,

            },
            'children': [
                'one child'
            ],
            'a_attr': {'class': 'hint--top', 'data-hint': 'Use a_attr to add tooltips'}
        },
        {
            'id': 'rn2',
            'text' : 'Opened node (has tooltip)',
            'state' : {
                'opened' : true,

            },
            'a_attr': {'class': 'hint--bottom', 'data-hint': 'This is a bottom mounted node tooltip'},
            'children' : [
                {
                  'text' : 'Child 1'
                },
                'Child 2'
            ]
        }
    ],
    addChildByText(id) {
    var data = this.get('data');
    data.forEach(function(node, index) {
    if (typeof node === 'object' && node["id"] === id) {
    data[index].children.push('added child');
    }
    });
    this.set('data', data);
    }




Aucun commentaire:

Enregistrer un commentaire