PDA

View Full Version : check div empty



raj_plays
27 May 2011, 2:42 AM
Hi,
I have a div in my page with id 'grid-div'.
How can I check if the div is empty or if it contains something(a panel)?

drian
28 May 2011, 7:10 AM
maybe check the "items" property?

raj_plays
29 May 2011, 4:55 AM
Can i check using
Ext.isEmpty('grid-div')?

fay
29 May 2011, 6:00 AM
From the docs (http://dev.sencha.com/deploy/ext-3.3.1/docs/?class=Ext&member=isEmpty):

isEmpty (http://dev.sencha.com/deploy/ext-3.3.1/docs/source/Ext.html#method-Ext-isEmpty)( Mixed value, [Boolean allowBlank] ) : Boolean

Returns true if the passed value is empty.

The value is deemed to be empty if it is

null
undefined
an empty array
a zero length string (Unless the allowBlank parameter is true)

To check if your div is empty, try:



if (Ext.get('grid-div').dom.innerHTML == '') {
// ...
}

raj_plays
30 May 2011, 6:10 AM
Thank you, fay