PDA

View Full Version : API DOM Help



srd161
17 Apr 2007, 6:08 AM
Is there a method to read non-standard attributes of DOM elements?

tryanDLS
17 Apr 2007, 6:56 AM
What is a 'non-standard attribute'. If the Element class doesn't expose a method to do what you want, you can still access the native dom property of the Element object and perform base dom functions. http://extjs.com/deploy/ext/docs/output/Ext.Element.html#dom

srd161
17 Apr 2007, 10:01 AM
Thank you for the response. Here is an example. <div id="myDiv" boo="yikes"> I would like to be able to read the boo attribute value of the div element. Prototype provides the readAttribute() method which is a simple wrapper for getAttribute and also helps with handling attributes in IE. I believe that YUI also has similar method YAHOO.util.Attribute.getValue(), but I'm not sure the exact usage. I was just wondering if there were was an ext wrapper.

xmrcivicboix
17 Apr 2007, 10:23 AM
Ext.get('myDiv').getAttribute('boo');

srd161
17 Apr 2007, 5:11 PM
This throws the error:

Ext.get("myDiv").getAttribute is not a function
[Break on this error] alert(Ext.get('myDiv').getAttribute('boo'));

tryanDLS
17 Apr 2007, 5:26 PM
Element does not have a getAttribute method. Did you try


Ext.get('mydiv').dom.getAttribute('boo')

xmrcivicboix
17 Apr 2007, 5:31 PM
ah... I knew I forgot something.

srd161
17 Apr 2007, 5:41 PM
Thank you again, this worked great! Just so I will know where to look next time, is there documentation on this method within either ext's or yui's api refernce?

tryanDLS
17 Apr 2007, 5:45 PM
getAttribute is a native DOM method. YUI may have a wrapper around it - you'd have to look at their API doc.