PDA

View Full Version : Howto clear the style field of an element?



joergd
22 Nov 2007, 3:24 AM
Hi,

I used my-element.position("absolute", null, x, y), which creates an inline style="position: absolute; left: 942px; top: 537px;" for example.

How do I completely reverse this, so that the inline style == "" ?

Thanks
Joerg

Animal
22 Nov 2007, 3:45 AM
http://extjs.com/deploy/dev/docs/?class=Ext.Element&member=setStyle

Animal
22 Nov 2007, 3:46 AM
or http://extjs.com/deploy/dev/docs/?class=Ext.Element&member=clearPositioning

joergd
22 Nov 2007, 4:17 AM
I've tries the clearPositioning, but it then replaces my inline style with "positioning: static", whereas I want it to be "".

joergd
22 Nov 2007, 4:24 AM
And my_element.setStyle("") or my_element.setStyle({}) leaves the inline style untouched ...

my_element.dom.style = "" doesn't work 'cos it's only a getter.

Are there any other ways?

Thanks
Joerg

joergd
22 Nov 2007, 4:32 AM
my_element.applyStyles("") also doesn't clear the inline style - it just leaves it untouched .... :-(

Animal
22 Nov 2007, 4:36 AM
Of course. You are not telling it what styles to set. It can't know.

joergd
22 Nov 2007, 4:48 AM
Hmm ... ok.

So basically to set my inline style to "", I need to first know what's in it, and then clear each style individually, like this:

my_element.applyStyles({ position:'', left:'', top:'' });

That undoes what my_element.position() created ...



Cool - thanks :-)

Joerg