Comments (11)
please also update the tag and bower file. Currently bower installing a very old version.
from jstree-directive.
Fixed. Please check. Also pushed the latest code to bower https://github.com/arvindr21/jsTree-directive/releases/tag/v0.1.3
from jstree-directive.
Can you confirm if the updated fix works as expected? I can release a new bower version.
from jstree-directive.
I left a comment on your last commit, but it seems github doesn't show it anywhere unless you open the commit itself. Well, please allow me copy the comment here.
+ // Trigger it initally
+ // Fix issue #13
+ treeDir.init(s, e, a, config);
the three lines you added here, seems the config object was not assigned to a correct value.
from jstree-directive.
I did see the comment and fixed it. Reopened the issue again, so we can track. Ref : 1efa940
from jstree-directive.
tested, and it's working, thank you for the quick response.
from jstree-directive.
Thanks! You use bower version 0.1.4
.
from jstree-directive.
Apologies for revisiting this issue, but I had some trouble with jsTree v3.0.9, which I fixed by commenting out the full // Trigger it initally
code of this fix. Namely, I had the following error thrown:
Callstack | File |
---|---|
Uncaught TypeError: Cannot read property 'triggerHandler' of null | jstree.js:857 |
$.jstree.core.trigger | jstree.js:857 |
$.jstree.core._append_json_data.rslt | jstree.js:1773 |
(anonymous function) | jstree.js:1802 |
n.extend.proxy.n.isFunction.e | jquery.min.js:2 |
I'm using a $resource
factory to get data from my API. For reference, the relevant parts of my code look somewhat like this:
angular.isUndefinedOrNull = function(val) {
return angular.isUndefined(val) || val === null
}
app.filter('jstree', function() {
return function( array ) {
return array.map( function( e, i, a ) {
// jsTree represents root nodes with parent = #
e.parent = e.category_id == 0 ? '#' : e.category_id;
delete e.category_id;
// See 'Alternative JSON Format'
// http://www.jstree.com/docs/json/
e.text = e.title;
delete e.title;
return e;
});
}
});
$scope.sidebarTree = [ { id: 1, parent: '#', text: 'Loading...' } ];
Category.get({}, function(data) {
$scope.categories = data.items;
});
$scope.$watch( 'categories', function (newVal, oldVal) {
if( !angular.isUndefinedOrNull( newVal ) ) {
$scope.sidebarTree = $filter('jstree')($scope.categories);
}
});
<js-tree tree-data="scope" tree-model="sidebarTree" ></js-tree>
Basically, I think that jsTree.directive
does not play nice when AJAX calls are used to build the model for tree-data="scope"
. Maybe the issue is on my end, but I wanted to bring this to your attention just in case it's something deeper.
Sorry for the snippet-heavy comment. Please let me know if I should clarify any info.
from jstree-directive.
@IllyaMoskvin Thanks. Can you try the below
$scope.$watch( 'categories', function (newVal, oldVal) {
console.log(newVal, oldVal);
if( !angular.isUndefinedOrNull( newVal ) ) {
var _tree = $filter('jstree')($scope.categories);
console.log(_tree);
$scope.sidebarTree = _tree;
}
});
and share the output here?
Thanks.
from jstree-directive.
Certainly. Thanks for the quick response! I truncated the existing table to create a simplified test case and verified that the bug still occurs. I also wrapped each variable inside the console.log()
calls in a JSON.stringify()
to make copying easier and to avoid running into the "Object state below is captured on first expansion" problem with Chrome. (JavaScript's default of passing non-trivial objects by reference gives me a headache.) Here is the output:
undefined undefined
[{"id":1,"category_id":0,"title":"Root Node"},{"id":2,"category_id":1,"title":"Foo"},{"id":3,"category_id":1,"title":"Bar"}] undefined
[{"id":1,"parent":"#","text":"Root Node"},{"id":2,"parent":1,"text":"Foo"},{"id":3,"parent":1,"text":"Bar"}]
Uncaught TypeError: Cannot read property 'triggerHandler' of null
I hope this helps! Thanks.
Edit[1]: Sorry, I forgot to mention that I changed the Category.get()
call to only retrieve the most relevant columns like so:
Category.get({key:'all',select:'id+category_id+title'}, function(data) {
$scope.categories = data.items;
});
My API URIs are structured according to this model, with entity=categories
in this case:
http://.../api/[:entity]/[:key]/[:select]
I have a position
column too, but I forgot to retrieve it in this test case.
Edit[2]: Also, I should mention that the tree does work properly in every way, despite the error being thrown.
Edit[3]: Well, I circumvented the aforementioned pass-by-reference by changing the $filter
definition to include array = $.extend( true, [], array );
before return array.map()
. Sorry, I know it's tangential, but that was the whole point of setting up a $watch
, and I forgot to include it in my code. I'll stop with the edits now. This had no effect on the bug in question.
from jstree-directive.
The same here with versione 0.1.5. The error is always:
Uncaught TypeError: Cannot read property 'triggerHandler' of null
I have fixed removed the line // Trigger it initally
mentioned by @IllyaMoskvin
But now with two jsTrees the error start to show again.
from jstree-directive.
Related Issues (20)
- AjaxTree Jquery Error HOT 2
- Sort plugin failed HOT 2
- Unable to get events HOT 1
- Issue with 2 trees, one of them loaded with state plugin HOT 6
- How to search with input-text into jsTree directive. HOT 1
- How can i call functions like reload on Js Tree HOT 1
- jstree instance HOT 4
- Problem with ngResource HOT 1
- Search input box position HOT 1
- Double click event binding HOT 1
- managing tree-ajax error
- Select a node inside the controller
- File Tree is not looking properly HOT 1
- Search box on the tope of tree HOT 1
- custom context menu doesnt work HOT 2
- Plans for Angular 2? HOT 1
- multiple instances of js-tree
- Updating when new file is created HOT 1
- Browser tab crashes on multiple refresh HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jstree-directive.