PDA

View Full Version : Ext.select( '.contact-forms' ).addCls('single') raises error



georgeadamson
24 Feb 2012, 7:46 AM
Simply attempting to find an element by class name and add another classname to it:


Ext.select( '.contact-forms' ).addCls('single')

This results in TypeError: Object [object Object] has no method 'attach'
Any idea why? I'm new to ExtJS and I thought this would be a really easy thing to do!

Cheers,
George

mitchellsimoens
24 Feb 2012, 12:30 PM
What is Ext.select( '.contact-forms' ) returning?

georgeadamson
24 Feb 2012, 12:53 PM
Thanks for responding.

Ext.select( '.contact-forms' ) returns this object:
Ext.apply.create.Class
el: Ext.apply.create.Class
elements: Array[1]
__proto__: TemplateClass

mitchellsimoens
24 Feb 2012, 12:56 PM
Ok good! So now look at the elements array and el properties. Can you find the element you want to add the CSS class to?

georgeadamson
24 Feb 2012, 1:16 PM
So to use addClass, do I have to pick out the one item from the array of one? Something like

Ext.select( '.contact-forms' ).elements[0].addCls('single')