views:

1270

answers:

3

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

+2  A: 

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?

bmoeskau
See http://www.extjs.com/deploy/dev/docs/?class=Ext.tree.TreeLoader( => Public Methods : load(...) :Load an Ext.tree.TreeNode from the URL specified in the constructor ==> Public Events : load: (...) Fires when the node has been successfuly loaded.) Two different things for the same object... maybe you're right maybe ... not.
Olivier Pons
+1  A: 

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.

Upper Stage
This wasn't the real problem but I'll keep your advice in mind, thanks.
Olivier Pons
+1  A: 

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.

Olivier Pons
Sorry I wasn't more specific -- I did not realize you were trying to handle the load event. Glad you got it sorted out.
bmoeskau