Results 1 to 8 of 8

Thread: No ID, please!

  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    39
    Answers
    5
    Vote Rating
    0
      0  

    Default Unanswered: No ID, please!

    Hi,

    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 :
    Code:
    var range = window.getSelection().getRangeAt(0);
    range.deleteContents();
    var b = document.createElement('b');
              b.appendChild(document.createTextNode(text));
          range.insertNode(b);
    }
    Notice, that I do not use any Ext JS functions here.
    But the element is contained in an element created by Ext JS...

    ?

  2. #2
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,146
    Answers
    87
    Vote Rating
    34
      0  

    Default

    Maybe you refer the the Ext.Element. In that case you can point to the dom like

    Code:
    yourElement.dom

  3. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    39
    Answers
    5
    Vote Rating
    0
      0  

    Default

    ?

    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.

  4. #4
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,146
    Answers
    87
    Vote Rating
    34
      0  

    Default

    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.

  5. #5
    Sencha User
    Join Date
    Nov 2011
    Posts
    39
    Answers
    5
    Vote Rating
    0
      0  

    Default

    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.

  6. #6
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,146
    Answers
    87
    Vote Rating
    34
      0  

    Default

    Hmm strange, maybe ext need them very badly

  7. #7
    Sencha User
    Join Date
    Nov 2011
    Posts
    39
    Answers
    5
    Vote Rating
    0
      0  

    Default

    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...
    Weird!

    I want turn this thing off!!

  8. #8
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,790
    Answers
    583
    Vote Rating
    390
      0  

    Default

    I believe this happens in the constructor for Ext.Element:

    http://docs.sencha.com/ext-js/4-0/source/Element.html

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •