Jstree has problem about multiple core data change

103 views
Skip to first unread message

Doğan Can Diktepe

unread,
Jun 12, 2020, 11:04:49 AM6/12/20
to jsTree
Hello guys,

I have a question about ajax and manually set data.

I have some small issue.

For example.

When u refresh the page first run "jstree" with ajax and then when ajax completed, I put a variable for JSON data and then when you click some button if the data has the variable. it should set core data but the list has children. When I gonna click node doesn't work ajax request again.

When I gonna put data and then click node element doesn't create ajax request again. 



Example:

$element.jstree({
    'themes': {
        'icon': false,
        'dots': false
    },
    'core': {
        'worker': false,
        'check_callback': true,
        data: function (nodecb) {
            //ajaxRequest start here.

            cb(ajaxResponse);
        }
    },
    'plugin' : ['themes']
});

function checkDataDom() {
   return globalData[groupId];
}

$(someButtonWithoutJstree).on('click'function(){
    var instance = $element.jstree(true);
    var checkDataDom = checkDataDom(); 
    if (checkDataDom) {
        instance.settings.core.data = checkDataDom;
        instance.refresh();
    } else {
        $element.jstree('refresh', -1);
    }
});


//first load and some click button without jstree element
{
    'id''c_15',
    'text''deneme',
    'children'true
}


// The Json only when u click some node and then response
{

    'id''t_15',
    'text''Parent 2',
    'parent''c_15'

}
Reply all
Reply to author
Forward
0 new messages