BUGFIX Adding jstree ajax settings after initial load

This commit is contained in:
Ingo Schommer 2011-03-18 10:11:30 +13:00
parent 6e60314006
commit 15d320ec91

View File

@ -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