1

I have a problem and don't know if this is a bug or I misunderstood something. I wanted to search for a component with a specific class. Example:

Ext.define('Test', {
  xtype: 'Test',
  cls: ['cat', 'dog']
});

I wanted to find this component I created in a Ext.Container with this.down('Test[cls~=cat]') (I used ~= because the component has multiple classes). But I got undefined or null (don't know anymore) as a result.

With Ext.ComponentQuery.query('Test[cls~=cat]') I actually could find it.

Why is that? I thought down() is the same as Ext.ComponentQuery.query with the difference that it's search scope is not global.

I am using the current version of Sencha Touch.

user2820280
  • 71
  • 1
  • 5

1 Answers1

0

No, this doesn't work. But you can use

this.query('Test[cls~=cat]')

or you use something like this:

Ext.ComponentQuery.pseudos.hasCls = function(items, cls) {
    var i = 0, l = items.length, c, result = [];
    for (; i < l; i++) {
        var c = items[i];
        if (c._cls && c._cls.indexOf(cls) > -1) {
            return c;
        }
    }
    return undefined;
};

and call it like:

this.down(".component:hasCls(cat)")
Dinkheller
  • 4,631
  • 5
  • 39
  • 67