PDA

View Full Version : [CLOSED][3.0 Core] (beta): Problem with Ext.CompositeElementLite.item



akva
24 Apr 2009, 1:56 PM
Hi all,
Ext.Element object returned by Ext.CompositeElementLite.item has no id attribute.
For example for this markup:

<h1 id="header">Hello Ext Core 3.0!</h1>

Ext.select('h1').item(0).id --> undefined

syscobra
24 Apr 2009, 6:35 PM
Hi all,
Ext.Element object returned by Ext.CompositeElementLite.item has no id attribute.
For example for this markup:

<h1 id="header">Hello Ext Core 3.0!</h1>

Ext.select('h1').item(0).id --> undefined

Hi there. I look into it and its this way:

Ext.select('h1').item(0).dom.id -->"header"

akva
25 Apr 2009, 12:27 AM
Hi there. I look into it and its this way:

Ext.select('h1').item(0).dom.id -->"header"

Well, according to the API documentation Ext.Element has an id attribute of its own. And when Ext.Element object is constructed in some other ways this attribute is set properly. For example

Ext.get('header').id --> "header"

So I presume that Ext.select('h1').item(0).id should also work.

akva
25 Apr 2009, 6:56 AM
Ok, I looked a little closer. Ext.CompositeElementLite.item returns a flyweight element and the flyweight element, in contrast to a regular Element, doesn't seem to have an id attribute in general:

Ext.fly('header').id --> undefined

Now the question is - is it intentional?

syscobra
25 Apr 2009, 8:59 AM
well i don't really know too much but i guess after seeing this that i will treat the fly or select DomQuerys as a pointer or a reference to the element. It has some of the features but not all, you have to access the complete element attributes with the dom then.

I was thinking why is this fly thing introduced and now i see its like a memory pointer to the element itself, or something like that. if you use Fly or Select you get a CompositeElement not an element at all. So when you use Ext.Get you GET the element, if you use Ext.fly or Ext.select or other that returns a CompositeElement and you use item() on this you get a Flyweight composite element(a POINTER) not an element at all.

In the CompositeElementLite API (http://www.extjs.com/products/extcore/docs/) description it says this about the item() on the Composite Element:

item( Number index ) : Ext.Element
Returns a flyweight Element of the dom element object at the specified index
Parameters:

* index : Number

Returns:

* Ext.Element
So it says it returns a flyweight Element, in the description, in the Returns it says it returns an Ext.Element but maybe thats a glitch in the manual. The return is a flyweight element that is a pointer or reference to the element, not the Element itself.

So this is my conclusion:
"To access that Element attributes you must use the .dom that encapsulates the real Element. To use the functions you can use it directly as the function points to the Element itself".

Well thats how i understand it, I dont know if i am wrong or if i just really confuse you more. Sorry if you cant understand me. /:), just try to get my point on what i think about this.

Cheers