squistbe
squistbe

Reputation: 305

How do you set a css class based on a select query in Sencha Touch?

I have a simple select query to select DOM node:

var selectNode = Ext.select('.myCSSClass textarea');

I want to apply a css class to textarea.

I have tried:

selectNode.addCls('newClass');

I have also tried using Ext.ComponentQuery to select the node and it doesn't work.

I also tried using the apply() method:

Ext.apply(selectNode, {
    cls: 'newClass'
});

Upvotes: 1

Views: 1835

Answers (1)

Titouan de Bailleul
Titouan de Bailleul

Reputation: 12949

Ext.select returns a array of elements that respond to the CSS selector you gave. If you want to add a CSS class to the class attribute of this element you have to do this :

Ext.select('.css-class').elements[0].className += ' myClass'; // don't forget the space

Example :

enter image description here

Hope this helps

Upvotes: 1

Related Questions