ExtJs: TreeLoader: it doesn't work but why?
If I do this : it works :
var myTreeLoader = new Ext.tree.TreeLoader({
dataUrl: 'json/test.php',
});
If I add this code it doesn't开发者_开发知识库 work :
var myTreeLoader = new Ext.tree.TreeLoader({
dataUrl: 'json/test.php',
load : function(loader,node,response) { }
});
My question is : why ? Edit/Delete Message
Well, you are overriding the built-in load()
method with an empty implementation. What were you expecting it to do if it can't load data?
Some browers (e.g. IE) won't like the trailing comma after dataUrl. Not sure if that is your problem here, but it's a never ending source of many JS problems.
The correct answer was:
var MyTreeLoader = new Ext.tree.TreeLoader({
dataUrl: 'json/lys.php',
listeners: {
load: function(loader,node,response) {
console.log('datas loaded');
}
}
});
Mr bmoeskau was right. I was overriding a function instead of add a listener.
精彩评论