ezraroi / ngJsTree

Angular Directive for the famous JS Tree
http://ezraroi.github.io/ngJsTree/
MIT License
270 stars 98 forks source link

Uncaught TypeError: Cannot read property 'triggerHandler' of null #84

Closed xunhuanhuan closed 8 years ago

ezraroi commented 8 years ago

Please provide code that reproduce

xunhuanhuan commented 8 years ago

app.controller("treeCtrl", function ($http,$scope,$log,$timeout) { var vm = this; var newId = 1; vm.ignoreChanges = false; vm.newNode = {}; $http({ url:'json/1.js', method:'GET', dataType: 'json' }).success(function(data,header,config,status){ vm.originalData = data; callback(); }).error(function(data,header,config,status){ }); vm.originalData = []; var callback = function() { vm.treeData = []; angular.copy(vm.originalData,vm.treeData); 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 }, version : 1, plugins : ['types','checkbox'] }; vm.addNewNode = function() { vm.treeData.push({ id : (newId++).toString(), parent : vm.newNode.parent, text : vm.newNode.text }); }; this.applyModelChanges = function() { return !vm.ignoreChanges; }; } })

xunhuanhuan commented 8 years ago

c9f0 tmp e0f6 tmp 22e0 tmp

xunhuanhuan commented 8 years ago

Click the button can not be increased

ezraroi commented 8 years ago

Please reproduce in plunker so i will be able to check

DoubleDot commented 8 years ago

I had the same issue, async loading the items from the backend. When removing the "treeConfig.version++" it works, but it doesn't update the view, as 'expected'.

I changed my html to do the following, to ensure my model data is loaded before loading the directive.

`

                    </div>`

I tried all the fixes provided here. Nothing seems to work except for the method above.