-
Notifications
You must be signed in to change notification settings - Fork 98
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
Crashes on Asyncronous load via angular query #99
Comments
<div js-tree="vm.treeConfig" ng-model="vm.nodes" tree="treeInstance" ></div> <!-- should-apply="ignoreModelChanges()" tree="treeInstance" tree-events="ready:readyCB;create_node:createNodeCB"></div> --> |
function HomeController ($scope, Principal, LoginService, $state, Node,AlertService) {
var vm = this;
//jstree
vm.ignoreChanges = false;
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']
};
//jstree
vm.nodes=[];
// load all
loadAll();
function loadAll () {
Node.query({}, onSuccess, onError);
function onSuccess(data, headers) {
for(var i=0;i<data.length;i++)
{
var node={};
node.id=data[i].idstr;
node.text=data[i].text;
node.parent=data[i].parent;
node.state={opened:true};
// node.children=data[i].children;
vm.nodes.push(node);
}
}
function onError(error) {
AlertService.error(error.data.message);
}
}
//load all |
Hi jmoseman01, i had the same problem i fixed it by setting the function reloadTree(){
vm.treeConfig.version ++;
}
_orgUnits.getOrganizationUnitsConfigModel().then(function (response) {
var treeModel = response.data;
for (var i = 0; i < treeModel.organizationUnits.length; i++) {
buildTreeData(treeModel.organizationUnits[i]);
}
reloadTree();
}); The problem is that you must call the reloadTree method every time you update the tree model. I hope it helps. |
No description provided.
The text was updated successfully, but these errors were encountered: