View Full Version : No ID, please!
30 Nov 2011, 7:48 AM
When I create an element with the DOM (or even with Ext functions) and I add it to my Ext container (or Component...), it seems to always create an id in the HTML code. But I don't want those dirty IDs.
For instance, here is how I create a bold style on the selected text :
var range = window.getSelection().getRangeAt(0);
var b = document.createElement('b');
Notice, that I do not use any Ext JS functions here.
But the element is contained in an element created by Ext JS...
30 Nov 2011, 8:08 AM
Maybe you refer the the Ext.Element. In that case you can point to the dom like
30 Nov 2011, 8:22 AM
Yeah, I know how to point to the DOM, but that's not the point.
What I'm telling is that, even with the code I wrote (see 1st post) with only DOM functions, when I append the DOM element to an other (that has been created with Ext JS), it automatically adds that id, that I don't want...
So the problem comes from a default behavior of Ext JS that automatically adds those ids and I want to know if and how I can disable these id generations for some tags I create or for a whole subtree.
30 Nov 2011, 8:51 AM
Do you mean that range.insertNode creates that id?
Maybe that method it overriden by ExtJs, I don't know. In that case you probably need to call its super class method.
30 Nov 2011, 9:05 AM
No. It can't be the insertNode method because, even when I add a b.removeAttribute('id') after calling the insertNode method, it doesn't remove the id.
So I think its a root Ext JS listener that watch the HTML tree and make sure every node has an id.
30 Nov 2011, 9:09 AM
Hmm strange, maybe ext need them very badly
30 Nov 2011, 9:19 AM
Another proof: when I'm creating a node (p for instance) containing some html (text and/or tags), it automatically creates ids for every tag inside the HTML String.
Then, even if I use the innerHTML property directly on the element and that I set some text + raw html inside, it creates ids for all tags...
I want turn this thing off!!
30 Nov 2011, 12:15 PM
I believe this happens in the constructor for Ext.Element:
Chances are there's something in your code creating an Ext.Element around that node. From what you've said I guess it must be something implicit as you aren't doing it yourself. Normally it won't add ids to every node, just the nodes it has some need to manipulate.
I'm not entirely sure why it does it. At a guess it's so that it has a string key for the element cache.
I don't think you can turn it off. Out of curiosity, why do you want to turn it off?
The only good reason I've seen suggested for turning it off is that it might help performance. I believe WebKit does some internal optimizations for node styling and they can't be applied to nodes with ids.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.