Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error while openning Parent Node in Case of lazy loading. #64

Open
Rabi-Narayan opened this issue Jan 25, 2016 · 3 comments
Open

Comments

@Rabi-Narayan
Copy link

jsfile.txt

Hi ezraroi,
modified in the way u suggested to make empty array and pushed the response data but it failed to create child nodes and gives error while trying to open a parent node.
treeCtrl: error from js tree - {"error":"nodata","plugin":"core","id":"core_05","reason":"Could not load node","data":"{"id":"ajson1"}"}

my config and data to load initial tree is like this.Given some initial data to populate tree because it is not creating any node in other ways.
vm.treeData = [
{ id : 'ajson1', parent : '#', text : 'Simple root node', state: { opened: false},children:true },
{ id : 'ajson2', parent : '#', text : 'Root node 2', state: { opened: false},children:true },
];

vm.treeConfig = {
    core : {
        multiple : false,
        animation: true,
        error : function(error) {
            $log.error('treeCtrl: error from js tree - ' + angular.toJson(error));
        },
        check_callback : true,
        worker : true
    },
    types : {
        default : {
            icon : 'glyphicon glyphicon-flash'
        },
        star : {
            icon : 'glyphicon glyphicon-star'
        },
        cloud : {
            icon : 'glyphicon glyphicon-cloud'
        }
    },
    version : 1,
    plugins : ['types','checkbox']
};

I am getting data from http service like this:

var promise = ravensService.getChildren();

I am calling the follwing function on "open_node" event of jsTree.But before this event i am getting above error :(
vm.openChildNode = function()
{
vm.treeData.push(data.data);
};

promise.then(function (data)
{
vm.treeData = data.data;
console.log(vm.treeData);
});

I have tried all the stuffs and working on same from days but unable to find solution.I am using jsTree in Angularjs.Since i am new to this please help in this regard.Thanks in advance.PFA for Js.

@ezraroi
Copy link
Owner

ezraroi commented Jan 28, 2016

Hi,
please write a plunker that reproduces your problem and I will try to look on it

@Rabi-Narayan
Copy link
Author

Thanks for the reply ezraroi.
Now i am doing ajax call inside the Jstree configuration itself.Now this issue is resolved.But can u please suggest me to get into solution for possibility of populating jstree by using REST services inside tree config ?If so is there any reference for guidance ??
Thanks in advance.

@icfantv
Copy link

icfantv commented Feb 18, 2016

@Rabi-Narayan, the right behavior in this case is to inject the necessary dependencies into your directive or controller before-hand either using resolve functions (for route navigation or, say, UIBS modals) or directly using promises.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants