View Full Version : Ext.Element & innerText / textContent

23 Nov 2009, 12:35 PM

Is there an Ext utility function to grab the inner text of an Ext.Element? For example, say I have the following paragraph element:

<p id="parag">I am some text <input type="button" value="blabla" /></p>

To grab just the text, there is a normal DOM property innerText/textContent. Browsers have different properties for accessing that text and I was wondering if Ext provides a utility function for grabbing the text without having to create some kind of cross browser compatibility function.

I've looked online and through the API but haven't found anything.


23 Nov 2009, 12:45 PM
See http://www.extjs.com/forum/showthread.php?t=82225

23 Nov 2009, 2:37 PM
Thanks for the reply.

I'm not entirely following what that override method in the last reply of that thread is doing, but it gave me the idea (along with a previous reply) to make something like this:

Ext.override(Ext.Element, {
getText: function() {
return this.dom.textContent || this.dom.innerText || "";

It seems to be working correctly for me, does anyone see anything blatantly wrong with it?

24 Nov 2009, 6:35 AM