Permalink
Browse files

BUGFIX Adding jstree ajax settings after initial load

  • Loading branch information...
chillu committed Mar 17, 2011
1 parent 6e60314 commit 15d320ec9150364d602ff0856f956443cc63ec78
Showing with 14 additions and 7 deletions.
  1. +14 −7 javascript/LeftAndMain.Tree.js
@@ -44,13 +44,7 @@
'html_titles': true
},
'html_data': {
- // TODO Hack to avoid ajax load on init, see http://code.google.com/p/jstree/issues/detail?id=911
- 'ajax': {
- 'url': this.data('url-tree'),
- 'data': function(node) {
- return { ID : $(node).data("id") ? $(node).data("id") : 0 , ajax: 1};
- }
- }
+ // 'ajax' will be set on 'loaded.jstree' event
},
'ui': {
"select_limit" : 1,
@@ -83,6 +77,19 @@
// 'plugins': ['html_data', 'ui', 'dnd', 'crrm', 'themeroller']
'plugins': ['html_data', 'ui', 'dnd', 'crrm', 'themes']
})
+ .bind('loaded.jstree', function(e, data) {
+ // Add ajax settings after init period to avoid unnecessary initial ajax load
+ // of existing tree in DOM - see load_node_html()
+ data.inst._set_settings({'html_data': {'ajax': {
+ 'url': self.data('url-tree'),
+ 'data': function(node) {
+ return $.extend(
+ self.data('searchparams') || {},
+ { ID : $(node).data("id") ? $(node).data("id") : 0 , ajax: 1}
+ );
+ }
+ }}});
+ })
.bind('before.jstree', function(e, data) {
if(data.func == 'start_drag') {
// Only allow drag'n'drop if it has been specifically enabled

0 comments on commit 15d320e

Please sign in to comment.