2

The problem is that the following gives error.

Ext.onReady(function() {

    Ext.select('nav li a').on('click', function(e) {

        var t = e.getTarget('a', 3, true);

        if(t){
            t.addClass('active');
        }

    });

});

The error i get on click:

Uncaught TypeError: Object [object Object] has no method 'addClass'

I've tried in many ways, read many tutorials but no luck.

4

1 回答 1

5

getTarget returns a raw HtmlElement. If you want to use Ext's addClass method you need to wrap the dom object in an `Ext.dom.Element'.

You can use Ext.fly to temporarily wrap an HtmlElement.

if (t) {
    Ext.fly(t).addCls('active');
}
于 2013-07-02T04:25:31.343 回答